@@ -1013,8 +1013,7 @@ bool SdBaseFile::openNext(SdBaseFile *dirFile, uint8_t oflag) {
1013
1013
* \return false if the dirname is a short file name 8.3 (SFN)
1014
1014
*/
1015
1015
bool SdBaseFile::isDirNameLFN (const char *dirname) {
1016
- uint8_t length = strlen (dirname);
1017
- uint8_t idx = length;
1016
+ uint8_t length = strlen (dirname), idx = length;
1018
1017
bool dotFound = false ;
1019
1018
if (idx > 12 ) return true ; // LFN due to filename length > 12 ("filename.ext")
1020
1019
// Check dot(s) position
@@ -1508,31 +1507,31 @@ int8_t SdBaseFile::readDir(dir_t *dir, char *longFilename) {
1508
1507
if (DIR_IS_FILE_OR_SUBDIR (dir)) {
1509
1508
#if ENABLED(UTF_FILENAME_SUPPORT)
1510
1509
#if LONG_FILENAME_CHARSIZE > 2
1511
- // Add warning for developers for currently not supported 3-byte cases (Conversion series of 2-byte
1512
- // codepoints to 3-byte in-place will break the rest of filename)
1510
+ // Add warning for developers for unsupported 3-byte cases.
1511
+ // (Converting 2-byte codepoints to 3-byte in-place would break the rest of filename. )
1513
1512
#error "Currently filename re-encoding is done in-place. It may break the remaining chars to use 3-byte codepoints."
1514
1513
#endif
1515
1514
1516
1515
// Is there a long filename to decode?
1517
1516
if (longFilename) {
1518
1517
// Reset n to the start of the long name
1519
1518
n = 0 ;
1520
- for (uint16_t idx = 0 ; idx < (LONG_FILENAME_LENGTH) / 2 ; idx += 2 ) { // idx is fixed since FAT LFN always contains UTF-16LE encoding
1519
+ for (uint16_t idx = 0 ; idx < (LONG_FILENAME_LENGTH); idx += 2 ) { // idx is fixed since FAT LFN always contains UTF-16LE encoding
1521
1520
const uint16_t utf16_ch = longFilename[idx] | (longFilename[idx + 1 ] << 8 );
1522
- if (0xD800 == (utf16_ch & 0xF800 )) // Surrogate pair - encode as '_'
1521
+ if (0xD800 == (utf16_ch & 0xF800 )) // Surrogate pair - encode as '_'
1523
1522
longFilename[n++] = ' _' ;
1524
- else if (0 == (utf16_ch & 0xFF80 )) // Encode as 1-byte UTF-8 char
1523
+ else if (0 == (utf16_ch & 0xFF80 )) // Encode as 1-byte UTF-8 char
1525
1524
longFilename[n++] = utf16_ch & 0x007F ;
1526
- else if (0 == (utf16_ch & 0xF800 )) { // Encode as 2-byte UTF-8 char
1525
+ else if (0 == (utf16_ch & 0xF800 )) { // Encode as 2-byte UTF-8 char
1527
1526
longFilename[n++] = 0xC0 | ((utf16_ch >> 6 ) & 0x1F );
1528
1527
longFilename[n++] = 0x80 | ( utf16_ch & 0x3F );
1529
1528
}
1530
1529
else {
1531
- #if LONG_FILENAME_CHARSIZE > 2 // Encode as 3-byte UTF-8 char
1530
+ #if LONG_FILENAME_CHARSIZE > 2 // Encode as 3-byte UTF-8 char
1532
1531
longFilename[n++] = 0xE0 | ((utf16_ch >> 12 ) & 0x0F );
1533
1532
longFilename[n++] = 0xC0 | ((utf16_ch >> 6 ) & 0x3F );
1534
1533
longFilename[n++] = 0xC0 | ( utf16_ch & 0x3F );
1535
- #else // Encode as '_'
1534
+ #else // Encode as '_'
1536
1535
longFilename[n++] = ' _' ;
1537
1536
#endif
1538
1537
}
0 commit comments