ESP32-S3 Arduino SD_MMC FAT long/short file names

copych
Posts: 20
Joined: Tue Mar 07, 2023 6:04 pm

ESP32-S3 Arduino SD_MMC FAT long/short file names

Postby copych » Thu Dec 21, 2023 5:15 pm

I iterate thru the SD card which was formatted as FAT and written on a PC, and search for *.wav files

Code: Select all

	File file = directory.openNextFile();
        tmp = file.name();
        Serial.printf("_Testing %s\r\n", tmp.c_str());
        if (file.isDirectory() || !(tmp.endsWith(".wav") || tmp.endsWith(".WAV"))) {
          // skip if it's a directory or not wav
        }
The problem is that filenames of the files that has long file names are displayed as empty strings, while 8.3 filenames are displayed correctly. Is there a way to work with various file names on an SD card prepared on a PC in Arduino IDE besides recompiling IDF components?
If they'd be shorten or modified in some way like, say, Windows did (SHORTE~1.TXT), that'd be fine.
Or maybe there's some way to open one particular file when we don't know it's name?

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32-S3 Arduino SD_MMC FAT long/short file names

Postby lbernstone » Fri Dec 22, 2023 4:23 pm

What is tmp? If your filenames include unicode, they may get mangled by trying to put them into a uint8_t array.

copych
Posts: 20
Joined: Tue Mar 07, 2023 6:04 pm

Re: ESP32-S3 Arduino SD_MMC FAT long/short file names

Postby copych » Wed Dec 27, 2023 7:13 am

Thank you for the help, your first guess was right. The problem was 'tmp', whose declaration I haven't even mentioned, my fault. I forgot that it was actually a fixed length string from a third party library, and on index overrun it silently nulled its content. Thanks!

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: ESP32-S3 Arduino SD_MMC FAT long/short file names

Postby lbernstone » Wed Dec 27, 2023 7:09 pm

Hey, it's good when they are easy to fix.

Who is online

Users browsing this forum: Bing [Bot] and 44 guests