Browse Source

Support for 10 level deep SD folder hierarchy

Scott Lahteine 11 years ago
parent
commit
a5cd582665
2 changed files with 17 additions and 7 deletions
  1. 13
    6
      Marlin/cardreader.cpp
  2. 4
    1
      Marlin/cardreader.h

+ 13
- 6
Marlin/cardreader.cpp View File

@@ -18,6 +18,8 @@ CardReader::CardReader()
18 18
    saving = false;
19 19
    logging = false;
20 20
    autostart_atmillis=0;
21
+   workDirDepth = 0;
22
+   memset(workDirParents, 0, sizeof(workDirParents));
21 23
 
22 24
    autostart_stilltocheck=true; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
23 25
    lastnr=0;
@@ -521,19 +523,24 @@ void CardReader::chdir(const char * relpath)
521 523
   }
522 524
   else
523 525
   {
524
-    workDirParentParent=workDirParent;
525
-    workDirParent=*parent;
526
-    
526
+    if (workDirDepth < MAX_DIR_DEPTH) {
527
+      for (int d = ++workDirDepth; d--;)
528
+        workDirParents[d+1] = workDirParents[d];
529
+      workDirParents[0]=*parent;
530
+    }
527 531
     workDir=newfile;
528 532
   }
529 533
 }
530 534
 
531 535
 void CardReader::updir()
532 536
 {
533
-  if(!workDir.isRoot())
537
+  if(workDirDepth > 0)
534 538
   {
535
-    workDir=workDirParent;
536
-    workDirParent=workDirParentParent;
539
+    --workDirDepth;
540
+    workDir = workDirParents[0];
541
+    int d;
542
+    for (int d = 0; d < workDirDepth; d++)
543
+      workDirParents[d] = workDirParents[d+1];
537 544
   }
538 545
 }
539 546
 

+ 4
- 1
Marlin/cardreader.h View File

@@ -3,6 +3,8 @@
3 3
 
4 4
 #ifdef SDSUPPORT
5 5
 
6
+#define MAX_DIR_DEPTH 10
7
+
6 8
 #include "SdFile.h"
7 9
 enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
8 10
 class CardReader
@@ -53,7 +55,8 @@ public:
53 55
   bool filenameIsDir;
54 56
   int lastnr; //last number of the autostart;
55 57
 private:
56
-  SdFile root,*curDir,workDir,workDirParent,workDirParentParent;
58
+  SdFile root,*curDir,workDir,workDirParents[MAX_DIR_DEPTH];
59
+  uint16_t workDirDepth;
57 60
   Sd2Card card;
58 61
   SdVolume volume;
59 62
   SdFile file;

Loading…
Cancel
Save