Skip to content

Commit 391804d

Browse files
author
3djc
committed
improve based on review
1 parent dc7f534 commit 391804d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

radio/src/lib_file.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ bool isExtensionMatching(const char * extension, const char * pattern, char * ma
9191
FRESULT sdReadDir(DIR * dir, FILINFO * fno, bool & firstTime)
9292
{
9393
FRESULT res;
94-
// cdir (0 == root) works on FAT and exFAT; f_getcwd() always reports root on exFAT.
95-
if (firstTime && dir->obj.fs->cdir != 0) {
94+
// Fake ".." only when browsing the non-root CWD itself (sclust == cdir, 0 == root).
95+
// Filesystem-CWD based so it works on exFAT, where f_getcwd() always returns root;
96+
// the sclust check keeps callers that open an arbitrary path (no chdir) unaffected.
97+
if (firstTime && dir->obj.fs->cdir != 0 && dir->obj.sclust == dir->obj.fs->cdir) {
9698
// fake parent directory entry
9799
strcpy(fno->fname, "..");
98100
fno->fattrib = AM_DIR;

0 commit comments

Comments
 (0)