File tree Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -367,9 +367,11 @@ void SDClass::end()
367367// this little helper is used to traverse paths
368368SdFile SDClass::getParentDir (const char *filepath, int *index) {
369369 // get parent directory
370- SdFile d1 = root; // start with the mostparent, root!
370+ SdFile d1;
371371 SdFile d2;
372372
373+ d1.openRoot (volume); // start with the mostparent, root!
374+
373375 // we'll use the pointers to swap between the two objects
374376 SdFile *parent = &d1;
375377 SdFile *subdir = &d2;
@@ -465,20 +467,11 @@ File SDClass::open(const char *filepath, uint8_t mode) {
465467 if (!parentdir.isOpen ())
466468 return File ();
467469
468- // there is a special case for the Root directory since its a static dir
469- if (parentdir.isRoot ()) {
470- if ( ! file.open (root, filepath, mode)) {
471- // failed to open the file :(
472- return File ();
473- }
474- // dont close the root!
475- } else {
476- if ( ! file.open (parentdir, filepath, mode)) {
477- return File ();
478- }
479- // close the parent
480- parentdir.close ();
470+ if ( ! file.open (parentdir, filepath, mode)) {
471+ return File ();
481472 }
473+ // close the parent
474+ parentdir.close ();
482475
483476 if ((mode & (O_APPEND | O_WRITE)) == (O_APPEND | O_WRITE))
484477 file.seekSet (file.fileSize ());
You can’t perform that action at this time.
0 commit comments