|
@@ -81,10 +81,10 @@ uint8_t CardReader::workDirDepth;
|
81
|
81
|
char **CardReader::sortshort, **CardReader::sortnames;
|
82
|
82
|
#else
|
83
|
83
|
char CardReader::sortshort[SDSORT_LIMIT][FILENAME_LENGTH];
|
84
|
|
- char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_MAXLEN];
|
|
84
|
+ char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_STORAGE];
|
85
|
85
|
#endif
|
86
|
86
|
#elif DISABLED(SDSORT_USES_STACK)
|
87
|
|
- char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_MAXLEN];
|
|
87
|
+ char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_STORAGE];
|
88
|
88
|
#endif
|
89
|
89
|
|
90
|
90
|
#if HAS_FOLDER_SORTING
|
|
@@ -760,11 +760,13 @@ void CardReader::setroot() {
|
760
|
760
|
#endif
|
761
|
761
|
#else
|
762
|
762
|
// Copy filenames into the static array
|
763
|
|
- #if SORTED_LONGNAME_MAXLEN != LONG_FILENAME_LENGTH
|
764
|
|
- #define SET_SORTNAME(I) do{ strncpy(sortnames[I], longest_filename(), SORTED_LONGNAME_MAXLEN); \
|
765
|
|
- sortnames[I][SORTED_LONGNAME_MAXLEN] = '\0'; }while(0)
|
|
763
|
+ #define _SET_SORTNAME(I) strncpy(sortnames[I], longest_filename(), SORTED_LONGNAME_MAXLEN)
|
|
764
|
+ #if SORTED_LONGNAME_MAXLEN == LONG_FILENAME_LENGTH
|
|
765
|
+ // Short name sorting always use LONG_FILENAME_LENGTH with no trailing nul
|
|
766
|
+ #define SET_SORTNAME(I) _SET_SORTNAME(I)
|
766
|
767
|
#else
|
767
|
|
- #define SET_SORTNAME(I) strncpy(sortnames[I], longest_filename(), SORTED_LONGNAME_MAXLEN)
|
|
768
|
+ // Copy multiple name blocks. Add a nul for the longest case.
|
|
769
|
+ #define SET_SORTNAME(I) do{ _SET_SORTNAME(I); sortnames[I][SORTED_LONGNAME_MAXLEN] = '\0'; }while(0)
|
768
|
770
|
#endif
|
769
|
771
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
770
|
772
|
#define SET_SORTSHORT(I) strcpy(sortshort[I], filename)
|
|
@@ -816,7 +818,7 @@ void CardReader::setroot() {
|
816
|
818
|
sortnames = new char*[fileCnt];
|
817
|
819
|
#endif
|
818
|
820
|
#elif ENABLED(SDSORT_USES_STACK)
|
819
|
|
- char sortnames[fileCnt][SORTED_LONGNAME_MAXLEN];
|
|
821
|
+ char sortnames[fileCnt][SORTED_LONGNAME_STORAGE];
|
820
|
822
|
#endif
|
821
|
823
|
|
822
|
824
|
// Folder sorting needs 1 bit per entry for flags.
|