Merge pull request #1739 from draeath/MK3-fix-sdcard-sorting
use modification times for sdcard time sorting. fixes #477
This commit is contained in:
commit
e56cb14bb9
@ -137,8 +137,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
|
|||||||
SERIAL_ECHOPGM("Access date: ");
|
SERIAL_ECHOPGM("Access date: ");
|
||||||
MYSERIAL.println(p.lastAccessDate);
|
MYSERIAL.println(p.lastAccessDate);
|
||||||
SERIAL_ECHOLNPGM("");*/
|
SERIAL_ECHOLNPGM("");*/
|
||||||
creationDate = p.creationDate;
|
modificationDate = p.lastWriteDate;
|
||||||
creationTime = p.creationTime;
|
modificationTime = p.lastWriteTime;
|
||||||
//writeDate = p.lastAccessDate;
|
//writeDate = p.lastAccessDate;
|
||||||
if (match != NULL) {
|
if (match != NULL) {
|
||||||
if (strcasecmp(match, filename) == 0) return;
|
if (strcasecmp(match, filename) == 0) return;
|
||||||
@ -763,8 +763,8 @@ void CardReader::presort() {
|
|||||||
#endif
|
#endif
|
||||||
#elif SDSORT_USES_STACK
|
#elif SDSORT_USES_STACK
|
||||||
char sortnames[fileCnt][LONG_FILENAME_LENGTH];
|
char sortnames[fileCnt][LONG_FILENAME_LENGTH];
|
||||||
uint16_t creation_time[fileCnt];
|
uint16_t modification_time[fileCnt];
|
||||||
uint16_t creation_date[fileCnt];
|
uint16_t modification_date[fileCnt];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Folder sorting needs 1 bit per entry for flags.
|
// Folder sorting needs 1 bit per entry for flags.
|
||||||
@ -784,8 +784,8 @@ void CardReader::presort() {
|
|||||||
// retaining only two filenames at a time. This is very
|
// retaining only two filenames at a time. This is very
|
||||||
// slow but is safest and uses minimal RAM.
|
// slow but is safest and uses minimal RAM.
|
||||||
char name1[LONG_FILENAME_LENGTH + 1];
|
char name1[LONG_FILENAME_LENGTH + 1];
|
||||||
uint16_t creation_time_bckp;
|
uint16_t modification_time_bckp;
|
||||||
uint16_t creation_date_bckp;
|
uint16_t modification_date_bckp;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
position = 0;
|
position = 0;
|
||||||
@ -811,8 +811,8 @@ void CardReader::presort() {
|
|||||||
#else
|
#else
|
||||||
// Copy filenames into the static array
|
// Copy filenames into the static array
|
||||||
strcpy(sortnames[i], LONGEST_FILENAME);
|
strcpy(sortnames[i], LONGEST_FILENAME);
|
||||||
creation_time[i] = creationTime;
|
modification_time[i] = modificationTime;
|
||||||
creation_date[i] = creationDate;
|
modification_date[i] = modificationDate;
|
||||||
#if SDSORT_CACHE_NAMES
|
#if SDSORT_CACHE_NAMES
|
||||||
strcpy(sortshort[i], filename);
|
strcpy(sortshort[i], filename);
|
||||||
#endif
|
#endif
|
||||||
@ -837,12 +837,12 @@ void CardReader::presort() {
|
|||||||
// Compare names from the array or just the two buffered names
|
// Compare names from the array or just the two buffered names
|
||||||
#if SDSORT_USES_RAM
|
#if SDSORT_USES_RAM
|
||||||
#define _SORT_CMP_NODIR() (strcasecmp(sortnames[o1], sortnames[o2]) > 0)
|
#define _SORT_CMP_NODIR() (strcasecmp(sortnames[o1], sortnames[o2]) > 0)
|
||||||
#define _SORT_CMP_TIME_NODIR() (((creation_date[o1] == creation_date[o2]) && (creation_time[o1] < creation_time[o2])) || \
|
#define _SORT_CMP_TIME_NODIR() (((modification_date[o1] == modification_date[o2]) && (modification_time[o1] < modification_time[o2])) || \
|
||||||
(creation_date[o1] < creation_date [o2]))
|
(modification_date[o1] < modification_date [o2]))
|
||||||
#else
|
#else
|
||||||
#define _SORT_CMP_NODIR() (strcasecmp(name1, name2) > 0) //true if lowercase(name1) > lowercase(name2)
|
#define _SORT_CMP_NODIR() (strcasecmp(name1, name2) > 0) //true if lowercase(name1) > lowercase(name2)
|
||||||
#define _SORT_CMP_TIME_NODIR() (((creation_date_bckp == creationDate) && (creation_time_bckp > creationTime)) || \
|
#define _SORT_CMP_TIME_NODIR() (((modification_date_bckp == modificationDate) && (modification_time_bckp > modificationTime)) || \
|
||||||
(creation_date_bckp > creationDate))
|
(modification_date_bckp > modificationDate))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -893,8 +893,8 @@ void CardReader::presort() {
|
|||||||
counter++;
|
counter++;
|
||||||
getfilename_simple(positions[o1]);
|
getfilename_simple(positions[o1]);
|
||||||
strcpy(name1, LONGEST_FILENAME); // save (or getfilename below will trounce it)
|
strcpy(name1, LONGEST_FILENAME); // save (or getfilename below will trounce it)
|
||||||
creation_date_bckp = creationDate;
|
modification_date_bckp = modificationDate;
|
||||||
creation_time_bckp = creationTime;
|
modification_time_bckp = modificationTime;
|
||||||
#if HAS_FOLDER_SORTING
|
#if HAS_FOLDER_SORTING
|
||||||
bool dir1 = filenameIsDir;
|
bool dir1 = filenameIsDir;
|
||||||
#endif
|
#endif
|
||||||
|
@ -77,7 +77,7 @@ public:
|
|||||||
bool cardOK ;
|
bool cardOK ;
|
||||||
bool paused ;
|
bool paused ;
|
||||||
char filename[13];
|
char filename[13];
|
||||||
uint16_t creationTime, creationDate;
|
uint16_t modificationTime, modificationDate;
|
||||||
uint32_t cluster, position;
|
uint32_t cluster, position;
|
||||||
char longFilename[LONG_FILENAME_LENGTH];
|
char longFilename[LONG_FILENAME_LENGTH];
|
||||||
bool filenameIsDir;
|
bool filenameIsDir;
|
||||||
@ -114,8 +114,8 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
#elif !SDSORT_USES_STACK
|
#elif !SDSORT_USES_STACK
|
||||||
char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
|
char sortnames[SDSORT_LIMIT][FILENAME_LENGTH];
|
||||||
uint16_t creation_time[SDSORT_LIMIT];
|
uint16_t modification_time[SDSORT_LIMIT];
|
||||||
uint16_t creation_date[SDSORT_LIMIT];
|
uint16_t modification_date[SDSORT_LIMIT];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Folder sorting uses an isDir array when caching items.
|
// Folder sorting uses an isDir array when caching items.
|
||||||
|
Loading…
Reference in New Issue
Block a user