|
@@ -45,7 +45,83 @@
|
45
|
45
|
#include "../feature/pause.h"
|
46
|
46
|
#endif
|
47
|
47
|
|
48
|
|
-#include <ctype.h>
|
|
48
|
+// public:
|
|
49
|
+
|
|
50
|
+card_flags_t CardReader::flag;
|
|
51
|
+char CardReader::filename[FILENAME_LENGTH + 1], CardReader::longFilename[LONG_FILENAME_LENGTH + 1];
|
|
52
|
+int8_t CardReader::autostart_index;
|
|
53
|
+
|
|
54
|
+#if ENABLED(FAST_FILE_TRANSFER)
|
|
55
|
+ #if NUM_SERIAL > 1
|
|
56
|
+ uint8_t CardReader::transfer_port;
|
|
57
|
+ #endif
|
|
58
|
+#endif
|
|
59
|
+
|
|
60
|
+// private:
|
|
61
|
+
|
|
62
|
+SdFile CardReader::root, CardReader::workDir, CardReader::workDirParents[MAX_DIR_DEPTH];
|
|
63
|
+uint8_t CardReader::workDirDepth;
|
|
64
|
+
|
|
65
|
+#if ENABLED(SDCARD_SORT_ALPHA)
|
|
66
|
+ uint16_t CardReader::sort_count;
|
|
67
|
+ #if ENABLED(SDSORT_GCODE)
|
|
68
|
+ bool CardReader::sort_alpha;
|
|
69
|
+ int CardReader::sort_folders;
|
|
70
|
+ //bool CardReader::sort_reverse;
|
|
71
|
+ #endif
|
|
72
|
+
|
|
73
|
+ #if ENABLED(SDSORT_DYNAMIC_RAM)
|
|
74
|
+ uint8_t *CardReader::sort_order;
|
|
75
|
+ #else
|
|
76
|
+ uint8_t CardReader::sort_order[SDSORT_LIMIT];
|
|
77
|
+ #endif
|
|
78
|
+
|
|
79
|
+ #if ENABLED(SDSORT_USES_RAM)
|
|
80
|
+
|
|
81
|
+ #if ENABLED(SDSORT_CACHE_NAMES)
|
|
82
|
+ #if ENABLED(SDSORT_DYNAMIC_RAM)
|
|
83
|
+ char **CardReader::sortshort, **CardReader::sortnames;
|
|
84
|
+ #else
|
|
85
|
+ char CardReader::sortshort[SDSORT_LIMIT][FILENAME_LENGTH + 1];
|
|
86
|
+ char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_MAXLEN + 1];
|
|
87
|
+ #endif
|
|
88
|
+ #elif DISABLED(SDSORT_USES_STACK)
|
|
89
|
+ char CardReader::sortnames[SDSORT_LIMIT][SORTED_LONGNAME_MAXLEN + 1];
|
|
90
|
+ #endif
|
|
91
|
+
|
|
92
|
+ #if HAS_FOLDER_SORTING
|
|
93
|
+ #if ENABLED(SDSORT_DYNAMIC_RAM)
|
|
94
|
+ uint8_t *CardReader::isDir;
|
|
95
|
+ #elif ENABLED(SDSORT_CACHE_NAMES) || DISABLED(SDSORT_USES_STACK)
|
|
96
|
+ uint8_t CardReader::isDir[(SDSORT_LIMIT+7)>>3];
|
|
97
|
+ #endif
|
|
98
|
+ #endif
|
|
99
|
+
|
|
100
|
+ #endif // SDSORT_USES_RAM
|
|
101
|
+
|
|
102
|
+#endif // SDCARD_SORT_ALPHA
|
|
103
|
+
|
|
104
|
+Sd2Card CardReader::sd2card;
|
|
105
|
+SdVolume CardReader::volume;
|
|
106
|
+SdFile CardReader::file;
|
|
107
|
+
|
|
108
|
+uint8_t CardReader::file_subcall_ctr;
|
|
109
|
+uint32_t CardReader::filespos[SD_PROCEDURE_DEPTH];
|
|
110
|
+char CardReader::proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH + 1];
|
|
111
|
+
|
|
112
|
+uint32_t CardReader::filesize, CardReader::sdpos;
|
|
113
|
+
|
|
114
|
+LsAction CardReader::lsAction; //stored for recursion.
|
|
115
|
+uint16_t CardReader::nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
|
|
116
|
+char *CardReader::diveDirName;
|
|
117
|
+
|
|
118
|
+#if ENABLED(AUTO_REPORT_SD_STATUS)
|
|
119
|
+ uint8_t CardReader::auto_report_sd_interval;
|
|
120
|
+ millis_t CardReader::next_sd_report_ms;
|
|
121
|
+ #if NUM_SERIAL > 1
|
|
122
|
+ int8_t CardReader::serialport;
|
|
123
|
+ #endif
|
|
124
|
+#endif
|
49
|
125
|
|
50
|
126
|
CardReader::CardReader() {
|
51
|
127
|
#if ENABLED(SDCARD_SORT_ALPHA)
|
|
@@ -56,9 +132,8 @@ CardReader::CardReader() {
|
56
|
132
|
//sort_reverse = false;
|
57
|
133
|
#endif
|
58
|
134
|
#endif
|
59
|
|
- sdprinting = cardOK = saving = logging = false;
|
60
|
|
- filesize = 0;
|
61
|
|
- sdpos = 0;
|
|
135
|
+ flag.sdprinting = flag.cardOK = flag.saving = flag.logging = false;
|
|
136
|
+ filesize = sdpos = 0;
|
62
|
137
|
file_subcall_ctr = 0;
|
63
|
138
|
|
64
|
139
|
workDirDepth = 0;
|
|
@@ -73,7 +148,7 @@ CardReader::CardReader() {
|
73
|
148
|
#endif
|
74
|
149
|
}
|
75
|
150
|
|
76
|
|
-char *createFilename(char *buffer, const dir_t &p) { //buffer > 12characters
|
|
151
|
+char *createFilename(char *buffer, const dir_t &p) {
|
77
|
152
|
char *pos = buffer;
|
78
|
153
|
for (uint8_t i = 0; i < 11; i++) {
|
79
|
154
|
if (p.name[i] == ' ') continue;
|
|
@@ -108,7 +183,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
|
108
|
183
|
if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) {
|
109
|
184
|
|
110
|
185
|
// Get the short name for the item, which we know is a folder
|
111
|
|
- char dosFilename[FILENAME_LENGTH];
|
|
186
|
+ char dosFilename[FILENAME_LENGTH + 1];
|
112
|
187
|
createFilename(dosFilename, p);
|
113
|
188
|
|
114
|
189
|
// Allocate enough stack space for the full path to a folder, trailing slash, and nul
|
|
@@ -120,8 +195,8 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
|
120
|
195
|
// It contains the full path to the "parent" argument.
|
121
|
196
|
// We now have the full path to the item in this folder.
|
122
|
197
|
strcpy(path, prepend_is_empty ? "/" : prepend); // root slash if prepend is empty
|
123
|
|
- strcat(path, dosFilename); // FILENAME_LENGTH-1 characters maximum
|
124
|
|
- strcat(path, "/"); // 1 character
|
|
198
|
+ strcat(path, dosFilename); // FILENAME_LENGTH characters maximum
|
|
199
|
+ strcat(path, "/"); // 1 character
|
125
|
200
|
|
126
|
201
|
// Serial.print(path);
|
127
|
202
|
|
|
@@ -150,9 +225,9 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
|
150
|
225
|
|
151
|
226
|
if (!DIR_IS_FILE_OR_SUBDIR(&p) || (p.attributes & DIR_ATT_HIDDEN)) continue;
|
152
|
227
|
|
153
|
|
- filenameIsDir = DIR_IS_SUBDIR(&p);
|
|
228
|
+ flag.filenameIsDir = DIR_IS_SUBDIR(&p);
|
154
|
229
|
|
155
|
|
- if (!filenameIsDir && (p.name[8] != 'G' || p.name[9] == '~')) continue;
|
|
230
|
+ if (!flag.filenameIsDir && (p.name[8] != 'G' || p.name[9] == '~')) continue;
|
156
|
231
|
|
157
|
232
|
switch (lsAction) { // 1 based file count
|
158
|
233
|
case LS_Count:
|
|
@@ -242,7 +317,7 @@ void CardReader::ls(
|
242
|
317
|
SERIAL_PROTOCOL_P(port, longFilename[0] ? longFilename : "???");
|
243
|
318
|
|
244
|
319
|
// If the filename was printed then that's it
|
245
|
|
- if (!filenameIsDir) break;
|
|
320
|
+ if (!flag.filenameIsDir) break;
|
246
|
321
|
|
247
|
322
|
// SERIAL_ECHOPGM_P(port, "Opening dir: "); SERIAL_ECHOLN_P(port, segment);
|
248
|
323
|
|
|
@@ -275,7 +350,7 @@ void CardReader::printFilename(
|
275
|
350
|
#endif
|
276
|
351
|
) {
|
277
|
352
|
if (file.isOpen()) {
|
278
|
|
- char dosFilename[FILENAME_LENGTH];
|
|
353
|
+ char dosFilename[FILENAME_LENGTH + 1];
|
279
|
354
|
file.getFilename(dosFilename);
|
280
|
355
|
SERIAL_ECHO_P(port, dosFilename);
|
281
|
356
|
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
|
|
@@ -293,7 +368,7 @@ void CardReader::printFilename(
|
293
|
368
|
}
|
294
|
369
|
|
295
|
370
|
void CardReader::initsd() {
|
296
|
|
- cardOK = false;
|
|
371
|
+ flag.cardOK = false;
|
297
|
372
|
if (root.isOpen()) root.close();
|
298
|
373
|
|
299
|
374
|
#ifndef SPI_SPEED
|
|
@@ -318,7 +393,7 @@ void CardReader::initsd() {
|
318
|
393
|
SERIAL_ERRORLNPGM(MSG_SD_OPENROOT_FAIL);
|
319
|
394
|
}
|
320
|
395
|
else {
|
321
|
|
- cardOK = true;
|
|
396
|
+ flag.cardOK = true;
|
322
|
397
|
SERIAL_ECHO_START();
|
323
|
398
|
SERIAL_ECHOLNPGM(MSG_SD_CARD_OK);
|
324
|
399
|
}
|
|
@@ -327,7 +402,7 @@ void CardReader::initsd() {
|
327
|
402
|
|
328
|
403
|
void CardReader::release() {
|
329
|
404
|
stopSDPrint();
|
330
|
|
- cardOK = false;
|
|
405
|
+ flag.cardOK = false;
|
331
|
406
|
}
|
332
|
407
|
|
333
|
408
|
void CardReader::openAndPrintFile(const char *name) {
|
|
@@ -339,8 +414,8 @@ void CardReader::openAndPrintFile(const char *name) {
|
339
|
414
|
}
|
340
|
415
|
|
341
|
416
|
void CardReader::startFileprint() {
|
342
|
|
- if (cardOK) {
|
343
|
|
- sdprinting = true;
|
|
417
|
+ if (flag.cardOK) {
|
|
418
|
+ flag.sdprinting = true;
|
344
|
419
|
#if SD_RESORT
|
345
|
420
|
flush_presort();
|
346
|
421
|
#endif
|
|
@@ -355,7 +430,7 @@ void CardReader::stopSDPrint(
|
355
|
430
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
356
|
431
|
did_pause_print = 0;
|
357
|
432
|
#endif
|
358
|
|
- sdprinting = abort_sd_printing = false;
|
|
433
|
+ flag.sdprinting = flag.abort_sd_printing = false;
|
359
|
434
|
if (isFileOpen()) file.close();
|
360
|
435
|
#if SD_RESORT
|
361
|
436
|
if (re_sort) presort();
|
|
@@ -363,7 +438,7 @@ void CardReader::stopSDPrint(
|
363
|
438
|
}
|
364
|
439
|
|
365
|
440
|
void CardReader::openLogFile(char * const path) {
|
366
|
|
- logging = true;
|
|
441
|
+ flag.logging = true;
|
367
|
442
|
openFile(path, false);
|
368
|
443
|
}
|
369
|
444
|
|
|
@@ -380,7 +455,7 @@ void CardReader::getAbsFilename(char *t) {
|
380
|
455
|
for (uint8_t i = 0; i < workDirDepth; i++) // Loop to current work dir
|
381
|
456
|
appendAtom(workDirParents[i], t, cnt);
|
382
|
457
|
|
383
|
|
- if (cnt < MAXPATHNAMELENGTH - (FILENAME_LENGTH)) {
|
|
458
|
+ if (cnt < MAXPATHNAMELENGTH - (FILENAME_LENGTH) - 1) { // Leave room for filename and nul
|
384
|
459
|
appendAtom(file, t, cnt);
|
385
|
460
|
--t;
|
386
|
461
|
}
|
|
@@ -389,7 +464,7 @@ void CardReader::getAbsFilename(char *t) {
|
389
|
464
|
|
390
|
465
|
void CardReader::openFile(char * const path, const bool read, const bool subcall/*=false*/) {
|
391
|
466
|
|
392
|
|
- if (!cardOK) return;
|
|
467
|
+ if (!flag.cardOK) return;
|
393
|
468
|
|
394
|
469
|
uint8_t doing = 0;
|
395
|
470
|
if (isFileOpen()) { // Replacing current file or doing a subroutine
|
|
@@ -464,7 +539,7 @@ void CardReader::openFile(char * const path, const bool read, const bool subcall
|
464
|
539
|
SERIAL_EOL();
|
465
|
540
|
}
|
466
|
541
|
else {
|
467
|
|
- saving = true;
|
|
542
|
+ flag.saving = true;
|
468
|
543
|
getfilename(0, fname);
|
469
|
544
|
#if ENABLED(EMERGENCY_PARSER)
|
470
|
545
|
emergency_parser.disable();
|
|
@@ -476,7 +551,7 @@ void CardReader::openFile(char * const path, const bool read, const bool subcall
|
476
|
551
|
}
|
477
|
552
|
|
478
|
553
|
void CardReader::removeFile(const char * const name) {
|
479
|
|
- if (!cardOK) return;
|
|
554
|
+ if (!flag.cardOK) return;
|
480
|
555
|
|
481
|
556
|
//stopSDPrint();
|
482
|
557
|
|
|
@@ -504,7 +579,7 @@ void CardReader::getStatus(
|
504
|
579
|
const int8_t port/*= -1*/
|
505
|
580
|
#endif
|
506
|
581
|
) {
|
507
|
|
- if (cardOK && sdprinting) {
|
|
582
|
+ if (flag.cardOK && flag.sdprinting) {
|
508
|
583
|
SERIAL_PROTOCOLPGM_P(port, MSG_SD_PRINTING_BYTE);
|
509
|
584
|
SERIAL_PROTOCOL_P(port, sdpos);
|
510
|
585
|
SERIAL_PROTOCOLCHAR_P(port, '/');
|
|
@@ -543,11 +618,11 @@ void CardReader::write_command(char *buf) {
|
543
|
618
|
|
544
|
619
|
void CardReader::checkautostart() {
|
545
|
620
|
|
546
|
|
- if (autostart_index < 0 || sdprinting) return;
|
|
621
|
+ if (autostart_index < 0 || flag.sdprinting) return;
|
547
|
622
|
|
548
|
|
- if (!cardOK) initsd();
|
|
623
|
+ if (!flag.cardOK) initsd();
|
549
|
624
|
|
550
|
|
- if (cardOK
|
|
625
|
+ if (flag.cardOK
|
551
|
626
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
552
|
627
|
&& !recovery.valid() // Don't run auto#.g when a resume file exists
|
553
|
628
|
#endif
|
|
@@ -576,7 +651,7 @@ void CardReader::beginautostart() {
|
576
|
651
|
void CardReader::closefile(const bool store_location) {
|
577
|
652
|
file.sync();
|
578
|
653
|
file.close();
|
579
|
|
- saving = logging = false;
|
|
654
|
+ flag.saving = flag.logging = false;
|
580
|
655
|
sdpos = 0;
|
581
|
656
|
#if ENABLED(EMERGENCY_PARSER)
|
582
|
657
|
emergency_parser.enable();
|
|
@@ -603,7 +678,7 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) {
|
603
|
678
|
if (nr < sort_count) {
|
604
|
679
|
strcpy(filename, sortshort[nr]);
|
605
|
680
|
strcpy(longFilename, sortnames[nr]);
|
606
|
|
- filenameIsDir = TEST(isDir[nr>>3], nr & 0x07);
|
|
681
|
+ flag.filenameIsDir = TEST(isDir[nr>>3], nr & 0x07);
|
607
|
682
|
return;
|
608
|
683
|
}
|
609
|
684
|
#endif // SDSORT_CACHE_NAMES
|
|
@@ -712,6 +787,33 @@ void CardReader::setroot() {
|
712
|
787
|
);
|
713
|
788
|
}
|
714
|
789
|
|
|
790
|
+ #if ENABLED(SDSORT_USES_RAM)
|
|
791
|
+ #if ENABLED(SDSORT_DYNAMIC_RAM)
|
|
792
|
+ // Use dynamic method to copy long filename
|
|
793
|
+ #define SET_SORTNAME(I) (sortnames[I] = strdup(longest_filename()))
|
|
794
|
+ #if ENABLED(SDSORT_CACHE_NAMES)
|
|
795
|
+ // When caching also store the short name, since
|
|
796
|
+ // we're replacing the getfilename() behavior.
|
|
797
|
+ #define SET_SORTSHORT(I) (sortshort[I] = strdup(filename))
|
|
798
|
+ #else
|
|
799
|
+ #define SET_SORTSHORT(I) NOOP
|
|
800
|
+ #endif
|
|
801
|
+ #else
|
|
802
|
+ // Copy filenames into the static array
|
|
803
|
+ #if SORTED_LONGNAME_MAXLEN != LONG_FILENAME_LENGTH
|
|
804
|
+ #define SET_SORTNAME(I) do{ strncpy(sortnames[I], longest_filename(), SORTED_LONGNAME_MAXLEN); \
|
|
805
|
+ sortnames[I][SORTED_LONGNAME_MAXLEN] = '\0'; }while(0)
|
|
806
|
+ #else
|
|
807
|
+ #define SET_SORTNAME(I) strncpy(sortnames[I], longest_filename(), SORTED_LONGNAME_MAXLEN)
|
|
808
|
+ #endif
|
|
809
|
+ #if ENABLED(SDSORT_CACHE_NAMES)
|
|
810
|
+ #define SET_SORTSHORT(I) strcpy(sortshort[I], filename)
|
|
811
|
+ #else
|
|
812
|
+ #define SET_SORTSHORT(I) NOOP
|
|
813
|
+ #endif
|
|
814
|
+ #endif
|
|
815
|
+ #endif
|
|
816
|
+
|
715
|
817
|
/**
|
716
|
818
|
* Read all the files and produce a sort key
|
717
|
819
|
*
|
|
@@ -754,7 +856,7 @@ void CardReader::setroot() {
|
754
|
856
|
sortnames = new char*[fileCnt];
|
755
|
857
|
#endif
|
756
|
858
|
#elif ENABLED(SDSORT_USES_STACK)
|
757
|
|
- char sortnames[fileCnt][SORTED_LONGNAME_MAXLEN];
|
|
859
|
+ char sortnames[fileCnt][SORTED_LONGNAME_MAXLEN + 1];
|
758
|
860
|
#endif
|
759
|
861
|
|
760
|
862
|
// Folder sorting needs 1 bit per entry for flags.
|
|
@@ -783,33 +885,15 @@ void CardReader::setroot() {
|
783
|
885
|
// If using RAM then read all filenames now.
|
784
|
886
|
#if ENABLED(SDSORT_USES_RAM)
|
785
|
887
|
getfilename(i);
|
786
|
|
- #if ENABLED(SDSORT_DYNAMIC_RAM)
|
787
|
|
- // Use dynamic method to copy long filename
|
788
|
|
- sortnames[i] = strdup(longest_filename());
|
789
|
|
- #if ENABLED(SDSORT_CACHE_NAMES)
|
790
|
|
- // When caching also store the short name, since
|
791
|
|
- // we're replacing the getfilename() behavior.
|
792
|
|
- sortshort[i] = strdup(filename);
|
793
|
|
- #endif
|
794
|
|
- #else
|
795
|
|
- // Copy filenames into the static array
|
796
|
|
- #if SORTED_LONGNAME_MAXLEN != LONG_FILENAME_LENGTH
|
797
|
|
- strncpy(sortnames[i], longest_filename(), SORTED_LONGNAME_MAXLEN);
|
798
|
|
- sortnames[i][SORTED_LONGNAME_MAXLEN - 1] = '\0';
|
799
|
|
- #else
|
800
|
|
- strncpy(sortnames[i], longest_filename(), SORTED_LONGNAME_MAXLEN);
|
801
|
|
- #endif
|
802
|
|
- #if ENABLED(SDSORT_CACHE_NAMES)
|
803
|
|
- strcpy(sortshort[i], filename);
|
804
|
|
- #endif
|
805
|
|
- #endif
|
|
888
|
+ SET_SORTNAME(i);
|
|
889
|
+ SET_SORTSHORT(i);
|
806
|
890
|
// char out[30];
|
807
|
|
- // sprintf_P(out, PSTR("---- %i %s %s"), i, filenameIsDir ? "D" : " ", sortnames[i]);
|
|
891
|
+ // sprintf_P(out, PSTR("---- %i %s %s"), i, flag.filenameIsDir ? "D" : " ", sortnames[i]);
|
808
|
892
|
// SERIAL_ECHOLN(out);
|
809
|
893
|
#if HAS_FOLDER_SORTING
|
810
|
894
|
const uint16_t bit = i & 0x07, ind = i >> 3;
|
811
|
895
|
if (bit == 0) isDir[ind] = 0x00;
|
812
|
|
- if (filenameIsDir) isDir[ind] |= _BV(bit);
|
|
896
|
+ if (flag.filenameIsDir) isDir[ind] |= _BV(bit);
|
813
|
897
|
#endif
|
814
|
898
|
#endif
|
815
|
899
|
}
|
|
@@ -837,7 +921,7 @@ void CardReader::setroot() {
|
837
|
921
|
? _SORT_CMP_NODIR() \
|
838
|
922
|
: (isDir[fs > 0 ? ind1 : ind2] & (fs > 0 ? _BV(bit1) : _BV(bit2))) != 0)
|
839
|
923
|
#else
|
840
|
|
- #define _SORT_CMP_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_NODIR() : (fs > 0 ? dir1 : !dir1))
|
|
924
|
+ #define _SORT_CMP_DIR(fs) ((dir1 == flag.filenameIsDir) ? _SORT_CMP_NODIR() : (fs > 0 ? dir1 : !dir1))
|
841
|
925
|
#endif
|
842
|
926
|
#endif
|
843
|
927
|
|
|
@@ -847,7 +931,7 @@ void CardReader::setroot() {
|
847
|
931
|
getfilename(o1);
|
848
|
932
|
strcpy(name1, longest_filename()); // save (or getfilename below will trounce it)
|
849
|
933
|
#if HAS_FOLDER_SORTING
|
850
|
|
- bool dir1 = filenameIsDir;
|
|
934
|
+ bool dir1 = flag.filenameIsDir;
|
851
|
935
|
#endif
|
852
|
936
|
getfilename(o2);
|
853
|
937
|
char *name2 = longest_filename(); // use the string in-place
|
|
@@ -885,27 +969,17 @@ void CardReader::setroot() {
|
885
|
969
|
else {
|
886
|
970
|
sort_order[0] = 0;
|
887
|
971
|
#if ENABLED(SDSORT_USES_RAM) && ENABLED(SDSORT_CACHE_NAMES)
|
888
|
|
- getfilename(0);
|
889
|
972
|
#if ENABLED(SDSORT_DYNAMIC_RAM)
|
890
|
973
|
sortnames = new char*[1];
|
891
|
|
- sortnames[0] = strdup(longest_filename()); // malloc
|
892
|
974
|
#if ENABLED(SDSORT_CACHE_NAMES)
|
893
|
975
|
sortshort = new char*[1];
|
894
|
|
- sortshort[0] = strdup(filename); // malloc
|
895
|
976
|
#endif
|
896
|
977
|
isDir = new uint8_t[1];
|
897
|
|
- #else
|
898
|
|
- #if SORTED_LONGNAME_MAXLEN != LONG_FILENAME_LENGTH
|
899
|
|
- strncpy(sortnames[0], longest_filename(), SORTED_LONGNAME_MAXLEN);
|
900
|
|
- sortnames[0][SORTED_LONGNAME_MAXLEN - 1] = '\0';
|
901
|
|
- #else
|
902
|
|
- strncpy(sortnames[0], longest_filename(), SORTED_LONGNAME_MAXLEN);
|
903
|
|
- #endif
|
904
|
|
- #if ENABLED(SDSORT_CACHE_NAMES)
|
905
|
|
- strcpy(sortshort[0], filename);
|
906
|
|
- #endif
|
907
|
978
|
#endif
|
908
|
|
- isDir[0] = filenameIsDir ? 0x01 : 0x00;
|
|
979
|
+ getfilename(0);
|
|
980
|
+ SET_SORTNAME(0);
|
|
981
|
+ SET_SORTSHORT(0);
|
|
982
|
+ isDir[0] = flag.filenameIsDir ? 0x01 : 0x00;
|
909
|
983
|
#endif
|
910
|
984
|
}
|
911
|
985
|
|
|
@@ -1007,7 +1081,7 @@ void CardReader::printingHasFinished() {
|
1007
|
1081
|
}
|
1008
|
1082
|
|
1009
|
1083
|
void CardReader::openJobRecoveryFile(const bool read) {
|
1010
|
|
- if (!cardOK) return;
|
|
1084
|
+ if (!flag.cardOK) return;
|
1011
|
1085
|
if (recovery.file.isOpen()) return;
|
1012
|
1086
|
if (!recovery.file.open(&root, job_recovery_file_name, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC)) {
|
1013
|
1087
|
SERIAL_PROTOCOLPAIR(MSG_SD_OPEN_FILE_FAIL, job_recovery_file_name);
|