From f21cce0b28db5215b7682eb42e05f3839578ed73 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Dec 2014 23:07:36 -0800 Subject: [PATCH] Rebase to Marlin_v1 --- Marlin/cardreader.cpp | 27 ++++++++++++++------------- Marlin/cardreader.h | 4 ++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Marlin/cardreader.cpp b/Marlin/cardreader.cpp index 913a9d1117..8694f6e5ca 100644 --- a/Marlin/cardreader.cpp +++ b/Marlin/cardreader.cpp @@ -49,7 +49,7 @@ char *createFilename(char *buffer, const dir_t &p) //buffer>12characters } -void CardReader::lsDive(const char *prepend,SdFile parent) +void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/) { dir_t p; uint8_t cnt=0; @@ -89,16 +89,12 @@ void CardReader::lsDive(const char *prepend,SdFile parent) } else { - if (p.name[0] == DIR_NAME_FREE) break; - if (p.name[0] == DIR_NAME_DELETED || p.name[0] == '.'|| p.name[0] == '_') continue; + char pn0 = p.name[0]; + if (pn0 == DIR_NAME_FREE) break; + if (pn0 == DIR_NAME_DELETED || pn0 == '.'|| pn0 == '_') continue; if (longFilename[0] != '\0' && (longFilename[0] == '.' || longFilename[0] == '_')) continue; - if ( p.name[0] == '.') - { - if ( p.name[1] != '.') - continue; - } - + if (!DIR_IS_FILE_OR_SUBDIR(&p)) continue; filenameIsDir=DIR_IS_SUBDIR(&p); @@ -120,7 +116,10 @@ void CardReader::lsDive(const char *prepend,SdFile parent) } else if(lsAction==LS_GetFilename) { - if (cnt == nrFiles) return; + if (match != NULL) { + if (strcasecmp(match, filename) == 0) return; + } + else if (cnt == nrFiles) return; cnt++; } } @@ -355,7 +354,8 @@ void CardReader::openFile(char* name,bool read, bool replace_current/*=true*/) sdpos = 0; SERIAL_PROTOCOLLNPGM(MSG_SD_FILE_SELECTED); - lcd_setstatus(fname); + getfilename(0, fname); + lcd_setstatus(longFilename[0] ? longFilename : fname); } else { @@ -560,7 +560,7 @@ void CardReader::closefile(bool store_location) } -void CardReader::getfilename(const uint16_t nr) +void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/) { #if defined(SDCARD_SORT_ALPHA) && SORT_USES_RAM && SORT_USES_MORE_RAM if (nr < sort_count) { @@ -574,7 +574,8 @@ void CardReader::getfilename(const uint16_t nr) lsAction=LS_GetFilename; nrFiles=nr; curDir->rewind(); - lsDive("",*curDir); + lsDive("",*curDir,match); + } uint16_t CardReader::getnrfilenames() diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h index f3af6da5b5..0ebcd50c83 100644 --- a/Marlin/cardreader.h +++ b/Marlin/cardreader.h @@ -35,7 +35,7 @@ public: void getStatus(); void printingHasFinished(); - void getfilename(const uint16_t nr); + void getfilename(uint16_t nr, const char* const match=NULL); uint16_t getnrfilenames(); void getAbsFilename(char *t); @@ -99,7 +99,7 @@ private: LsAction lsAction; //stored for recursion. uint16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory. char* diveDirName; - void lsDive(const char *prepend,SdFile parent); + void lsDive(const char *prepend, SdFile parent, const char * const match=NULL); }; extern CardReader card; #define IS_SD_PRINTING (card.sdprinting)