|
|
@ -43,8 +43,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
|
|
|
|
#define LONGEST_FILENAME (longFilename[0] ? longFilename : filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CardReader::CardReader() {
|
|
|
|
CardReader::CardReader() {
|
|
|
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
|
|
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
|
|
|
sort_count = 0;
|
|
|
|
sort_count = 0;
|
|
|
@ -771,7 +769,7 @@ void CardReader::setroot() {
|
|
|
|
getfilename(i);
|
|
|
|
getfilename(i);
|
|
|
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
|
|
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
|
|
|
// Use dynamic method to copy long filename
|
|
|
|
// Use dynamic method to copy long filename
|
|
|
|
sortnames[i] = strdup(LONGEST_FILENAME);
|
|
|
|
sortnames[i] = strdup(longest_filename());
|
|
|
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
|
|
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
|
|
|
// When caching also store the short name, since
|
|
|
|
// When caching also store the short name, since
|
|
|
|
// we're replacing the getfilename() behavior.
|
|
|
|
// we're replacing the getfilename() behavior.
|
|
|
@ -780,10 +778,10 @@ void CardReader::setroot() {
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
// Copy filenames into the static array
|
|
|
|
// Copy filenames into the static array
|
|
|
|
#if SORTED_LONGNAME_MAXLEN != LONG_FILENAME_LENGTH
|
|
|
|
#if SORTED_LONGNAME_MAXLEN != LONG_FILENAME_LENGTH
|
|
|
|
strncpy(sortnames[i], LONGEST_FILENAME, SORTED_LONGNAME_MAXLEN);
|
|
|
|
strncpy(sortnames[i], longest_filename(), SORTED_LONGNAME_MAXLEN);
|
|
|
|
sortnames[i][SORTED_LONGNAME_MAXLEN - 1] = '\0';
|
|
|
|
sortnames[i][SORTED_LONGNAME_MAXLEN - 1] = '\0';
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
strncpy(sortnames[i], LONGEST_FILENAME, SORTED_LONGNAME_MAXLEN);
|
|
|
|
strncpy(sortnames[i], longest_filename(), SORTED_LONGNAME_MAXLEN);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
|
|
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
|
|
|
strcpy(sortshort[i], filename);
|
|
|
|
strcpy(sortshort[i], filename);
|
|
|
@ -831,12 +829,12 @@ void CardReader::setroot() {
|
|
|
|
// throughout the loop. Slow if there are many.
|
|
|
|
// throughout the loop. Slow if there are many.
|
|
|
|
#if DISABLED(SDSORT_USES_RAM)
|
|
|
|
#if DISABLED(SDSORT_USES_RAM)
|
|
|
|
getfilename(o1);
|
|
|
|
getfilename(o1);
|
|
|
|
strcpy(name1, LONGEST_FILENAME); // save (or getfilename below will trounce it)
|
|
|
|
strcpy(name1, longest_filename()); // save (or getfilename below will trounce it)
|
|
|
|
#if HAS_FOLDER_SORTING
|
|
|
|
#if HAS_FOLDER_SORTING
|
|
|
|
bool dir1 = filenameIsDir;
|
|
|
|
bool dir1 = filenameIsDir;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
getfilename(o2);
|
|
|
|
getfilename(o2);
|
|
|
|
char *name2 = LONGEST_FILENAME; // use the string in-place
|
|
|
|
char *name2 = longest_filename(); // use the string in-place
|
|
|
|
#endif // !SDSORT_USES_RAM
|
|
|
|
#endif // !SDSORT_USES_RAM
|
|
|
|
|
|
|
|
|
|
|
|
// Sort the current pair according to settings.
|
|
|
|
// Sort the current pair according to settings.
|
|
|
@ -874,7 +872,7 @@ void CardReader::setroot() {
|
|
|
|
getfilename(0);
|
|
|
|
getfilename(0);
|
|
|
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
|
|
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
|
|
|
sortnames = new char*[1];
|
|
|
|
sortnames = new char*[1];
|
|
|
|
sortnames[0] = strdup(LONGEST_FILENAME); // malloc
|
|
|
|
sortnames[0] = strdup(longest_filename()); // malloc
|
|
|
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
|
|
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
|
|
|
sortshort = new char*[1];
|
|
|
|
sortshort = new char*[1];
|
|
|
|
sortshort[0] = strdup(filename); // malloc
|
|
|
|
sortshort[0] = strdup(filename); // malloc
|
|
|
@ -882,10 +880,10 @@ void CardReader::setroot() {
|
|
|
|
isDir = new uint8_t[1];
|
|
|
|
isDir = new uint8_t[1];
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
#if SORTED_LONGNAME_MAXLEN != LONG_FILENAME_LENGTH
|
|
|
|
#if SORTED_LONGNAME_MAXLEN != LONG_FILENAME_LENGTH
|
|
|
|
strncpy(sortnames[0], LONGEST_FILENAME, SORTED_LONGNAME_MAXLEN);
|
|
|
|
strncpy(sortnames[0], longest_filename(), SORTED_LONGNAME_MAXLEN);
|
|
|
|
sortnames[0][SORTED_LONGNAME_MAXLEN - 1] = '\0';
|
|
|
|
sortnames[0][SORTED_LONGNAME_MAXLEN - 1] = '\0';
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
strncpy(sortnames[0], LONGEST_FILENAME, SORTED_LONGNAME_MAXLEN);
|
|
|
|
strncpy(sortnames[0], longest_filename(), SORTED_LONGNAME_MAXLEN);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
|
|
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
|
|
|
strcpy(sortshort[0], filename);
|
|
|
|
strcpy(sortshort[0], filename);
|
|
|
|