This commit is contained in:
Scott Lahteine 2020-11-12 22:24:26 -06:00 committed by GitHub
parent 6eee9bbaa9
commit 8008c6c897
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1122,10 +1122,9 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
} }
} }
#if ENABLED(UTF_FILENAME_SUPPORT) // Post-process normal file or subdirectory longname, if any
// Return if normal file or subdirectory
if (DIR_IS_FILE_OR_SUBDIR(dir)) { if (DIR_IS_FILE_OR_SUBDIR(dir)) {
// Convert filename from utf-16 to utf-8 as Marlin expects #if ENABLED(UTF_FILENAME_SUPPORT)
#if LONG_FILENAME_CHARSIZE > 2 #if LONG_FILENAME_CHARSIZE > 2
// Add warning for developers for currently not supported 3-byte cases (Conversion series of 2-byte // Add warning for developers for currently not supported 3-byte cases (Conversion series of 2-byte
// codepoints to 3-byte in-place will break the rest of filename) // codepoints to 3-byte in-place will break the rest of filename)
@ -1133,8 +1132,7 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
#endif #endif
// Is there a long filename to decode? // Is there a long filename to decode?
if (!longFilename) return n; // sizeof(dir_t) if (longFilename) {
// Reset n to the start of the long name // Reset n to the start of the long name
n = 0; n = 0;
for (uint16_t idx = 0; idx < (LONG_FILENAME_LENGTH) / 2; idx += 2) { // idx is fixed since FAT LFN always contains UTF-16LE encoding for (uint16_t idx = 0; idx < (LONG_FILENAME_LENGTH) / 2; idx += 2) { // idx is fixed since FAT LFN always contains UTF-16LE encoding
@ -1157,10 +1155,11 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
#endif #endif
} }
if (0 == utf16_ch) break; // End of filename if (0 == utf16_ch) break; // End of filename
} } // idx
return n; } // longFilename
}
#endif #endif
return n;
} // DIR_IS_FILE_OR_SUBDIR
} }
} }