mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-24 04:29:34 +00:00
Clarify SD longname string size (#14148)
This commit is contained in:
parent
5f42d3a8b4
commit
5515f88452
@ -81,10 +81,10 @@ uint8_t CardReader::workDirDepth;
|
||||
char **CardReader::sortshort, **CardReader::sortnames;
|
||||
#else
|
||||
char CardReader::sortshort[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||
char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_MAXLEN];
|
||||
char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_STORAGE];
|
||||
#endif
|
||||
#elif DISABLED(SDSORT_USES_STACK)
|
||||
char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_MAXLEN];
|
||||
char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_STORAGE];
|
||||
#endif
|
||||
|
||||
#if HAS_FOLDER_SORTING
|
||||
@ -760,11 +760,13 @@ void CardReader::setroot() {
|
||||
#endif
|
||||
#else
|
||||
// Copy filenames into the static array
|
||||
#if SORTED_LONGNAME_MAXLEN != LONG_FILENAME_LENGTH
|
||||
#define SET_SORTNAME(I) do{ strncpy(sortnames[I], longest_filename(), SORTED_LONGNAME_MAXLEN); \
|
||||
sortnames[I][SORTED_LONGNAME_MAXLEN] = '\0'; }while(0)
|
||||
#define _SET_SORTNAME(I) strncpy(sortnames[I], longest_filename(), SORTED_LONGNAME_MAXLEN)
|
||||
#if SORTED_LONGNAME_MAXLEN == LONG_FILENAME_LENGTH
|
||||
// Short name sorting always use LONG_FILENAME_LENGTH with no trailing nul
|
||||
#define SET_SORTNAME(I) _SET_SORTNAME(I)
|
||||
#else
|
||||
#define SET_SORTNAME(I) strncpy(sortnames[I], longest_filename(), SORTED_LONGNAME_MAXLEN)
|
||||
// Copy multiple name blocks. Add a nul for the longest case.
|
||||
#define SET_SORTNAME(I) do{ _SET_SORTNAME(I); sortnames[I][SORTED_LONGNAME_MAXLEN] = '\0'; }while(0)
|
||||
#endif
|
||||
#if ENABLED(SDSORT_CACHE_NAMES)
|
||||
#define SET_SORTSHORT(I) strcpy(sortshort[I], filename)
|
||||
@ -816,7 +818,7 @@ void CardReader::setroot() {
|
||||
sortnames = new char*[fileCnt];
|
||||
#endif
|
||||
#elif ENABLED(SDSORT_USES_STACK)
|
||||
char sortnames[fileCnt][SORTED_LONGNAME_MAXLEN];
|
||||
char sortnames[fileCnt][SORTED_LONGNAME_STORAGE];
|
||||
#endif
|
||||
|
||||
// Folder sorting needs 1 bit per entry for flags.
|
||||
|
@ -175,9 +175,11 @@ private:
|
||||
#endif
|
||||
|
||||
#if BOTH(SDSORT_USES_RAM, SDSORT_CACHE_NAMES) && DISABLED(SDSORT_DYNAMIC_RAM)
|
||||
#define SORTED_LONGNAME_MAXLEN ((SDSORT_CACHE_VFATS) * (FILENAME_LENGTH) + 1)
|
||||
#define SORTED_LONGNAME_MAXLEN (SDSORT_CACHE_VFATS) * (FILENAME_LENGTH)
|
||||
#define SORTED_LONGNAME_STORAGE (SORTED_LONGNAME_MAXLEN + 1)
|
||||
#else
|
||||
#define SORTED_LONGNAME_MAXLEN LONG_FILENAME_LENGTH
|
||||
#define SORTED_LONGNAME_STORAGE SORTED_LONGNAME_MAXLEN
|
||||
#endif
|
||||
|
||||
// Cache filenames to speed up SD menus.
|
||||
@ -189,10 +191,11 @@ private:
|
||||
static char **sortshort, **sortnames;
|
||||
#else
|
||||
static char sortshort[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||
static char sortnames[SDSORT_LIMIT][SORTED_LONGNAME_MAXLEN];
|
||||
#endif
|
||||
#elif DISABLED(SDSORT_USES_STACK)
|
||||
static char sortnames[SDSORT_LIMIT][SORTED_LONGNAME_MAXLEN];
|
||||
#endif
|
||||
|
||||
#if (ENABLED(SDSORT_CACHE_NAMES) && DISABLED(SDSORT_DYNAMIC_RAM)) || NONE(SDSORT_CACHE_NAMES, SDSORT_USES_STACK)
|
||||
static char sortnames[SDSORT_LIMIT][SORTED_LONGNAME_STORAGE];
|
||||
#endif
|
||||
|
||||
// Folder sorting uses an isDir array when caching items.
|
||||
|
Loading…
Reference in New Issue
Block a user