Fixes #2623: several fixes:
Disable menu for [..], Refresh file list after delete, Copy destination can be a directory, Prevent copy/paste into the same directory, Enabled renaming of directories and files without extension, Removed delete menu option for directories, Several simulator filesystem functions improved
This commit is contained in:
committed by
Bertrand Songis
parent
f5f1a052ca
commit
28b9a70e6b
@@ -7,6 +7,7 @@
|
|||||||
<li>9XE top LDC fixes: added TX battery blinking on battery warning, fixed display problem when battery voltage lower than batlow value. (<a href=https://github.com/opentx/opentx/issues/2671>#2671</a>)</li>
|
<li>9XE top LDC fixes: added TX battery blinking on battery warning, fixed display problem when battery voltage lower than batlow value. (<a href=https://github.com/opentx/opentx/issues/2671>#2671</a>)</li>
|
||||||
<li>Timers range extended (it was limited to around 9 hours before) (<a href=https://github.com/opentx/opentx/issues/2702>#2702</a>)</li>
|
<li>Timers range extended (it was limited to around 9 hours before) (<a href=https://github.com/opentx/opentx/issues/2702>#2702</a>)</li>
|
||||||
<li>Fixed: Playing two background sounds at once causes sound to stop (<a href=https://github.com/opentx/opentx/issues/2704>#2704</a>)</li>
|
<li>Fixed: Playing two background sounds at once causes sound to stop (<a href=https://github.com/opentx/opentx/issues/2704>#2704</a>)</li>
|
||||||
|
<li>Several fixes to the SD card manager menu (<a href=https://github.com/opentx/opentx/issues/2623>#2623</a>)</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
[Sky9x / 9XR-PRO]
|
[Sky9x / 9XR-PRO]
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include "../../opentx.h"
|
#include "../../opentx.h"
|
||||||
|
|
||||||
#define REFRESH_FILES() reusableBuffer.sdmanager.offset = 65535
|
#define REFRESH_FILES() reusableBuffer.sdmanager.offset = 65535; m_posVert = 0;
|
||||||
|
|
||||||
void menuGeneralSdManagerInfo(uint8_t event)
|
void menuGeneralSdManagerInfo(uint8_t event)
|
||||||
{
|
{
|
||||||
@@ -172,19 +172,31 @@ void onSdManagerMenu(const char *result)
|
|||||||
}
|
}
|
||||||
else if (result == STR_PASTE) {
|
else if (result == STR_PASTE) {
|
||||||
f_getcwd(lfn, _MAX_LFN);
|
f_getcwd(lfn, _MAX_LFN);
|
||||||
POPUP_WARNING(fileCopy(clipboard.data.sd.filename, clipboard.data.sd.directory, lfn));
|
// if destination is dir, copy into that dir
|
||||||
REFRESH_FILES();
|
if (!line[SD_SCREEN_FILE_LENGTH+1]) {
|
||||||
|
strcat(lfn, PSTR("/"));
|
||||||
|
strcat(lfn, line);
|
||||||
|
}
|
||||||
|
if (strcmp(clipboard.data.sd.directory, lfn)) { // prevent copying to the same directory
|
||||||
|
POPUP_WARNING(fileCopy(clipboard.data.sd.filename, clipboard.data.sd.directory, lfn));
|
||||||
|
REFRESH_FILES();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (result == STR_RENAME_FILE) {
|
else if (result == STR_RENAME_FILE) {
|
||||||
|
memcpy(reusableBuffer.sdmanager.originalName, line, sizeof(reusableBuffer.sdmanager.originalName));
|
||||||
char *ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1);
|
char *ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1);
|
||||||
if (ext) {
|
if (ext) {
|
||||||
memcpy(reusableBuffer.sdmanager.originalName, line, sizeof(reusableBuffer.sdmanager.originalName));
|
|
||||||
// write spaces to allow a longer filename
|
// write spaces to allow a longer filename
|
||||||
memset(ext, ' ', SD_SCREEN_FILE_LENGTH-LEN_FILE_EXTENSION-(ext-line));
|
memset(ext, ' ', SD_SCREEN_FILE_LENGTH-LEN_FILE_EXTENSION-(ext-line));
|
||||||
line[SD_SCREEN_FILE_LENGTH-LEN_FILE_EXTENSION] = '\0';
|
line[SD_SCREEN_FILE_LENGTH-LEN_FILE_EXTENSION] = '\0';
|
||||||
s_editMode = EDIT_MODIFY_STRING;
|
|
||||||
editNameCursorPos = 0;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
int len = strlen(line);
|
||||||
|
memset(line + strlen(line), ' ', SD_SCREEN_FILE_LENGTH - len);
|
||||||
|
line[SD_SCREEN_FILE_LENGTH] = '\0';
|
||||||
|
}
|
||||||
|
s_editMode = EDIT_MODIFY_STRING;
|
||||||
|
editNameCursorPos = 0;
|
||||||
}
|
}
|
||||||
else if (result == STR_DELETE_FILE) {
|
else if (result == STR_DELETE_FILE) {
|
||||||
getSelectionFullPath(lfn);
|
getSelectionFullPath(lfn);
|
||||||
@@ -193,9 +205,6 @@ void onSdManagerMenu(const char *result)
|
|||||||
strcpy_P(statusLineMsg+min((uint8_t)strlen(statusLineMsg), (uint8_t)13), STR_REMOVED);
|
strcpy_P(statusLineMsg+min((uint8_t)strlen(statusLineMsg), (uint8_t)13), STR_REMOVED);
|
||||||
showStatusLine();
|
showStatusLine();
|
||||||
REFRESH_FILES();
|
REFRESH_FILES();
|
||||||
if (m_posVert == reusableBuffer.sdmanager.count-1) {
|
|
||||||
m_posVert--;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (result == STR_PLAY_FILE) {
|
else if (result == STR_PLAY_FILE) {
|
||||||
getSelectionFullPath(lfn);
|
getSelectionFullPath(lfn);
|
||||||
@@ -296,6 +305,9 @@ void menuGeneralSdManager(uint8_t _event)
|
|||||||
killEvents(_event);
|
killEvents(_event);
|
||||||
char *line = reusableBuffer.sdmanager.lines[index];
|
char *line = reusableBuffer.sdmanager.lines[index];
|
||||||
char *ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1);
|
char *ext = getFileExtension(line, SD_SCREEN_FILE_LENGTH+1);
|
||||||
|
if (!strcasecmp(line, "..")) {
|
||||||
|
break; // no menu for parent dir
|
||||||
|
}
|
||||||
if (ext) {
|
if (ext) {
|
||||||
if (!strcasecmp(ext, SOUNDS_EXT)) {
|
if (!strcasecmp(ext, SOUNDS_EXT)) {
|
||||||
MENU_ADD_ITEM(STR_PLAY_FILE);
|
MENU_ADD_ITEM(STR_PLAY_FILE);
|
||||||
@@ -331,7 +343,8 @@ void menuGeneralSdManager(uint8_t _event)
|
|||||||
if (clipboard.type == CLIPBOARD_TYPE_SD_FILE)
|
if (clipboard.type == CLIPBOARD_TYPE_SD_FILE)
|
||||||
MENU_ADD_ITEM(STR_PASTE);
|
MENU_ADD_ITEM(STR_PASTE);
|
||||||
MENU_ADD_ITEM(STR_RENAME_FILE);
|
MENU_ADD_ITEM(STR_RENAME_FILE);
|
||||||
MENU_ADD_ITEM(STR_DELETE_FILE);
|
if (line[SD_SCREEN_FILE_LENGTH+1])
|
||||||
|
MENU_ADD_ITEM(STR_DELETE_FILE);
|
||||||
}
|
}
|
||||||
menuHandler = onSdManagerMenu;
|
menuHandler = onSdManagerMenu;
|
||||||
}
|
}
|
||||||
@@ -388,7 +401,7 @@ void menuGeneralSdManager(uint8_t _event)
|
|||||||
char *line = reusableBuffer.sdmanager.lines[i];
|
char *line = reusableBuffer.sdmanager.lines[i];
|
||||||
if (line[0] == '\0' || isFilenameLower(isfile, fn, line)) {
|
if (line[0] == '\0' || isFilenameLower(isfile, fn, line)) {
|
||||||
if (i < 6) memmove(reusableBuffer.sdmanager.lines[i+1], line, sizeof(reusableBuffer.sdmanager.lines[i]) * (6-i));
|
if (i < 6) memmove(reusableBuffer.sdmanager.lines[i+1], line, sizeof(reusableBuffer.sdmanager.lines[i]) * (6-i));
|
||||||
memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[i]));
|
memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[0]));
|
||||||
strcpy(line, fn);
|
strcpy(line, fn);
|
||||||
line[SD_SCREEN_FILE_LENGTH+1] = isfile;
|
line[SD_SCREEN_FILE_LENGTH+1] = isfile;
|
||||||
break;
|
break;
|
||||||
@@ -400,7 +413,7 @@ void menuGeneralSdManager(uint8_t _event)
|
|||||||
char *line = reusableBuffer.sdmanager.lines[i];
|
char *line = reusableBuffer.sdmanager.lines[i];
|
||||||
if (line[0] == '\0' || isFilenameGreater(isfile, fn, line)) {
|
if (line[0] == '\0' || isFilenameGreater(isfile, fn, line)) {
|
||||||
if (i > 0) memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], sizeof(reusableBuffer.sdmanager.lines[0]) * i);
|
if (i > 0) memmove(reusableBuffer.sdmanager.lines[0], reusableBuffer.sdmanager.lines[1], sizeof(reusableBuffer.sdmanager.lines[0]) * i);
|
||||||
memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[i]));
|
memset(line, 0, sizeof(reusableBuffer.sdmanager.lines[0]));
|
||||||
strcpy(line, fn);
|
strcpy(line, fn);
|
||||||
line[SD_SCREEN_FILE_LENGTH+1] = isfile;
|
line[SD_SCREEN_FILE_LENGTH+1] = isfile;
|
||||||
break;
|
break;
|
||||||
@@ -441,6 +454,9 @@ void menuGeneralSdManager(uint8_t _event)
|
|||||||
if (ext) {
|
if (ext) {
|
||||||
strAppend(&reusableBuffer.sdmanager.lines[i][len], ext);
|
strAppend(&reusableBuffer.sdmanager.lines[i][len], ext);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
reusableBuffer.sdmanager.lines[i][len] = 0;
|
||||||
|
}
|
||||||
f_rename(reusableBuffer.sdmanager.originalName, reusableBuffer.sdmanager.lines[i]);
|
f_rename(reusableBuffer.sdmanager.originalName, reusableBuffer.sdmanager.lines[i]);
|
||||||
REFRESH_FILES();
|
REFRESH_FILES();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -929,14 +929,24 @@ FRESULT f_mkdir (const TCHAR*)
|
|||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
FRESULT f_unlink (const TCHAR*)
|
FRESULT f_unlink (const TCHAR* name)
|
||||||
{
|
{
|
||||||
|
char *path = convertSimuPath(name);
|
||||||
|
if (unlink(path)) {
|
||||||
|
TRACE("f_unlink(%s) = error %d (%s)", path, errno, strerror(errno));
|
||||||
|
return FR_INVALID_NAME;
|
||||||
|
}
|
||||||
|
TRACE("f_unlink(%s) = OK", path);
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
FRESULT f_rename(const TCHAR *oldname, const TCHAR *newname)
|
FRESULT f_rename(const TCHAR *oldname, const TCHAR *newname)
|
||||||
{
|
{
|
||||||
TRACE("f_rename(%s, %s)", oldname, newname);
|
if ( rename(oldname, newname) < 0) {
|
||||||
|
TRACE("f_rename(%s, %s) = error %d (%s)", oldname, newname, errno, strerror(errno));
|
||||||
|
return FR_INVALID_NAME;
|
||||||
|
}
|
||||||
|
TRACE("f_rename(%s, %s) = OK", oldname, newname);
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -966,7 +976,12 @@ int f_printf (FIL *fil, const TCHAR * format, ...)
|
|||||||
|
|
||||||
FRESULT f_getcwd (TCHAR *path, UINT sz_path)
|
FRESULT f_getcwd (TCHAR *path, UINT sz_path)
|
||||||
{
|
{
|
||||||
strcpy(path, ".");
|
// remove simuSdDirectory from the cwd
|
||||||
|
char * cwd = get_current_dir_name();
|
||||||
|
std::string c(cwd + strlen(simuSdDirectory));
|
||||||
|
free(cwd);
|
||||||
|
strcpy(path, c.c_str());
|
||||||
|
TRACE("f_getcwd() = %s", path);
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user