From 0385acea7a99b6de654162719e40a1eb5635febf Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Tue, 29 Mar 2016 03:18:53 -0700
Subject: [PATCH] Fix workDirParents -> getAbsFilename relationship
---
Marlin/cardreader.cpp | 15 ++++-----------
Marlin/cardreader.h | 2 +-
2 files changed, 5 insertions(+), 12 deletions(-)
diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp
index 63fcc9f473..6410f9f0b1 100644
--- a/Marlin/cardreader.cpp
+++ b/Marlin/cardreader.cpp
@@ -584,22 +584,15 @@ void CardReader::chdir(const char * relpath) {
SERIAL_ECHOLN(relpath);
}
else {
- if (workDirDepth < MAX_DIR_DEPTH) {
- ++workDirDepth;
- for (int d = workDirDepth; d--;) workDirParents[d + 1] = workDirParents[d];
- workDirParents[0] = *parent;
- }
+ if (workDirDepth < MAX_DIR_DEPTH)
+ workDirParents[workDirDepth++] = *parent;
workDir = newfile;
}
}
void CardReader::updir() {
- if (workDirDepth > 0) {
- --workDirDepth;
- workDir = workDirParents[0];
- for (uint16_t d = 0; d < workDirDepth; d++)
- workDirParents[d] = workDirParents[d+1];
- }
+ if (workDirDepth > 0)
+ workDir = workDirParents[--workDirDepth];
}
void CardReader::printingHasFinished() {
diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h
index d04043159f..b86900a667 100644
--- a/Marlin/cardreader.h
+++ b/Marlin/cardreader.h
@@ -79,7 +79,7 @@ public:
int autostart_index;
private:
SdFile root, *curDir, workDir, workDirParents[MAX_DIR_DEPTH];
- uint16_t workDirDepth;
+ uint8_t workDirDepth;
Sd2Card card;
SdVolume volume;
SdFile file;
--
GitLab