Browse Source

Fetch longname when a file exists

Scott Lahteine 3 years ago
parent
commit
660420050b
1 changed files with 6 additions and 0 deletions
  1. 6
    0
      Marlin/src/sd/cardreader.cpp

+ 6
- 0
Marlin/src/sd/cardreader.cpp View File

628
 
628
 
629
 //
629
 //
630
 // Check if a file exists by absolute or workDir-relative path
630
 // Check if a file exists by absolute or workDir-relative path
631
+// If the file exists, the long name can also be fetched.
631
 //
632
 //
632
 bool CardReader::fileExists(const char * const path) {
633
 bool CardReader::fileExists(const char * const path) {
633
   if (!isMounted()) return false;
634
   if (!isMounted()) return false;
634
   SdFile *diveDir = nullptr;
635
   SdFile *diveDir = nullptr;
635
   const char * const fname = diveToFile(false, diveDir, path);
636
   const char * const fname = diveToFile(false, diveDir, path);
637
+  if (fname) {
638
+    diveDir->rewind();
639
+    selectByName(*diveDir, fname);
640
+    diveDir->close();
641
+  }
636
   return fname != nullptr;
642
   return fname != nullptr;
637
 }
643
 }
638
 
644
 

Loading…
Cancel
Save