From 672636ff1d05d2e21052dfd9701cb1f1372a838b Mon Sep 17 00:00:00 2001 From: Christopher Williams Date: Wed, 9 Jan 2019 17:19:32 -0700 Subject: [PATCH] R0.13c patch 2 January 9, 2019 f_readdir() function returns file names with wrong case conversion. When the directory item to be read has a file name within 8.3 format, the extension of file name returned in fname[] is in wrong case conversion depends on the body length and the case. --- source/ff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/ff.c b/source/ff.c index 7b04676..9f96465 100644 --- a/source/ff.c +++ b/source/ff.c @@ -2649,6 +2649,7 @@ static void get_fileinfo ( { UINT si, di; #if FF_USE_LFN + BYTE lcf; WCHAR wc, hs; FATFS *fs = dp->obj.fs; #else @@ -2709,9 +2710,10 @@ static void get_fileinfo ( if (di == 0) { /* If LFN and SFN both are invalid, this object is inaccesible */ fno->fname[di++] = '?'; } else { - for (si = di = 0; fno->altname[si]; si++, di++) { /* Copy altname[] to fname[] with case information */ + for (si = di = 0, lcf = NS_BODY; fno->altname[si]; si++, di++) { /* Copy altname[] to fname[] with case information */ wc = (WCHAR)fno->altname[si]; - if (IsUpper(wc) && (dp->dir[DIR_NTres] & ((si >= 9) ? NS_EXT : NS_BODY))) wc += 0x20; + if (wc == '.') lcf = NS_EXT; + if (IsUpper(wc) && (dp->dir[DIR_NTres] & lcf)) wc += 0x20; fno->fname[di] = (TCHAR)wc; } }