|
@@ -55,6 +55,7 @@
|
55
|
55
|
|
56
|
56
|
#define DEBUG_OUT EITHER(DEBUG_CARDREADER, MARLIN_DEV_MODE)
|
57
|
57
|
#include "../core/debug_out.h"
|
|
58
|
+#include "../libs/hex_print.h"
|
58
|
59
|
|
59
|
60
|
// public:
|
60
|
61
|
|
|
@@ -796,9 +797,12 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile*& diveDir, cons
|
796
|
797
|
// Parsing the path string
|
797
|
798
|
const char *item_name_adr = path;
|
798
|
799
|
|
|
800
|
+ DEBUG_ECHOLNPAIR("diveToFile: path = '", path, "'");
|
|
801
|
+
|
799
|
802
|
if (path[0] == '/') { // Starting at the root directory?
|
800
|
803
|
diveDir = &root;
|
801
|
804
|
item_name_adr++;
|
|
805
|
+ DEBUG_ECHOLNPAIR("diveToFile: CWD to root: ", hex_address((void*)diveDir));
|
802
|
806
|
if (update_cwd) workDirDepth = 0; // The cwd can be updated for the benefit of sub-programs
|
803
|
807
|
}
|
804
|
808
|
else
|
|
@@ -806,6 +810,8 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile*& diveDir, cons
|
806
|
810
|
|
807
|
811
|
startDir = diveDir;
|
808
|
812
|
|
|
813
|
+ DEBUG_ECHOLNPAIR("diveToFile: startDir = ", hex_address((void*)startDir));
|
|
814
|
+
|
809
|
815
|
while (item_name_adr) {
|
810
|
816
|
// Find next subdirectory delimiter
|
811
|
817
|
char * const name_end = strchr(item_name_adr, '/');
|
|
@@ -821,6 +827,8 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile*& diveDir, cons
|
821
|
827
|
|
822
|
828
|
if (echo) SERIAL_ECHOLN(dosSubdirname);
|
823
|
829
|
|
|
830
|
+ DEBUG_ECHOLNPAIR("diveToFile: sub = ", hex_address((void*)sub));
|
|
831
|
+
|
824
|
832
|
// Open diveDir (closing first)
|
825
|
833
|
sub->close();
|
826
|
834
|
if (!sub->open(diveDir, dosSubdirname, O_READ)) {
|
|
@@ -830,19 +838,25 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile*& diveDir, cons
|
830
|
838
|
}
|
831
|
839
|
|
832
|
840
|
// Close diveDir if not at starting-point
|
833
|
|
- if (diveDir != startDir) diveDir->close();
|
|
841
|
+ if (diveDir != startDir) {
|
|
842
|
+ DEBUG_ECHOLNPAIR("diveToFile: closing diveDir: ", hex_address((void*)diveDir));
|
|
843
|
+ diveDir->close();
|
|
844
|
+ }
|
834
|
845
|
|
835
|
846
|
// diveDir now subDir
|
836
|
847
|
diveDir = sub;
|
|
848
|
+ DEBUG_ECHOLNPAIR("diveToFile: diveDir = sub: ", hex_address((void*)diveDir));
|
837
|
849
|
|
838
|
850
|
// Update workDirParents and workDirDepth
|
839
|
851
|
if (update_cwd) {
|
|
852
|
+ DEBUG_ECHOLNPAIR("diveToFile: update_cwd");
|
840
|
853
|
if (workDirDepth < MAX_DIR_DEPTH)
|
841
|
854
|
workDirParents[workDirDepth++] = *diveDir;
|
842
|
855
|
}
|
843
|
856
|
|
844
|
857
|
// Point sub at the other scratch object
|
845
|
858
|
sub = (diveDir != &newDir1) ? &newDir1 : &newDir2;
|
|
859
|
+ DEBUG_ECHOLNPAIR("diveToFile: swapping sub = ", hex_address((void*)sub));
|
846
|
860
|
|
847
|
861
|
// Next path atom address
|
848
|
862
|
item_name_adr = name_end + 1;
|
|
@@ -850,6 +864,7 @@ const char* CardReader::diveToFile(const bool update_cwd, SdFile*& diveDir, cons
|
850
|
864
|
|
851
|
865
|
if (update_cwd) {
|
852
|
866
|
workDir = *diveDir;
|
|
867
|
+ DEBUG_ECHOLNPAIR("diveToFile: final workDir = ", hex_address((void*)diveDir));
|
853
|
868
|
flag.workDirIsRoot = (workDirDepth == 0);
|
854
|
869
|
TERN_(SDCARD_SORT_ALPHA, presort());
|
855
|
870
|
}
|