From 8d1c5cbb27c51d0e27ada070814e6dc0a20e983b Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 9 Feb 2021 20:29:06 +0200 Subject: [PATCH] Fix position table offset --- Firmware/cardreader.cpp | 11 ++++++----- Firmware/cardreader.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 9e7d2f011..0d61b5f49 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -77,7 +77,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m dir_t p; uint8_t cnt = 0; // Read the next entry from a directory - while (parent.readDir(p, longFilename) > 0) { + for (position = parent.curPosition(); parent.readDir(p, longFilename) > 0; position = parent.curPosition()) { if (recursionCnt > MAX_DIR_DEPTH) return; else if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) { // If the entry is a directory and the action is LS_SerialPrint @@ -144,10 +144,10 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m break; case LS_GetFilename: - //SERIAL_ECHOPGM("File: "); + //SERIAL_ECHOPGM("File: "); createFilename(filename, p); - cluster = parent.curCluster(); - position = parent.curPosition(); + // cluster = parent.curCluster(); + // position = parent.curPosition(); /*MYSERIAL.println(filename); SERIAL_ECHOPGM("Write date: "); writeDate = p.lastWriteDate; @@ -792,9 +792,9 @@ void CardReader::presort() { for (uint16_t i = 0; i < fileCnt; i++) { if (!IS_SD_INSERTED) return; manage_heater(); + getfilename(i); sort_order[i] = i; sort_positions[i] = position; - getfilename(i); #if HAS_FOLDER_SORTING if (filenameIsDir) dirCnt++; #endif @@ -966,6 +966,7 @@ void CardReader::presort() { } else { sort_order[0] = 0; + sort_positions[0] = position; } sort_count = fileCnt; diff --git a/Firmware/cardreader.h b/Firmware/cardreader.h index 5c59e20b2..9b5c5196d 100644 --- a/Firmware/cardreader.h +++ b/Firmware/cardreader.h @@ -74,7 +74,7 @@ public: // There are scenarios when simple modification time is not enough (on MS Windows) // Therefore these timestamps hold the most recent one of creation/modification date/times uint16_t crmodTime, crmodDate; - uint32_t cluster, position; + uint32_t /* cluster, */ position; char longFilename[LONG_FILENAME_LENGTH]; bool filenameIsDir; int lastnr; //last number of the autostart;