[En-Nut-Discussion] shot filenames in nut- PHAT fs
PragmaLab
info at pragmalab.nl
Tue Sep 30 14:45:50 CEST 2008
Hello all,
we are currently using the PHAT filesystem to store lots of audio-files on a
SD-card. While trying to store files that came with the name 'Track001.mp3',
'Track002.mp3' ..... 'Track300.mp3' etc we noticed that after some time the
files could not be created on the card anymore (fopen returned an error).
After some debugging, it turned out that the 'GenShortName()' routine was
the problem: the routine was not able to create unique a short name (DOS 8.3
name) for the longfile name that was offered.
Funny thing was that it actually did not have to create a unique short
filename since the 'long' filename that was offered, was already in the 8.3
format and so the long filename could easily be used as the short filename.
But besides that, I think the algoritm to create a unique filename is a bit
too simple. If I offer the following 'long' filenames:
Track001.mp3
Track010.mp3
Track011.mp3
it will create the correspoding short filenames as follows:
TRACK~01.MP3
TRACK~10.MP3
TRACK~11.MP3
Now I offer 'Track110.mp3' and the routine will fail to create a unique
filename: all possibilities (with the current algoritm) are already used.
The code tells me
/*
* We try up to 99 unique short names only, but this should be
* sufficient for our tiny system - hopefully.
*/
but I'm not sure that is completely true. In some occasions it might try 99
possibilities, but when using enumeration in the filename coding, it fails
after 4 attempts (I can even think of a scenario in which it fails sooner).
I already modified the code in 'phatdir.c' in a way that it does not try to
create a short name in case the long name is already in the 8.3 format. That
for now solves our problem. But I was wondering:
- did other Nut-users run into the same issue before?
- do I overlook something trivial here?
- anybody knows a better algoritm that tries harder to create unique 8.3
filenames?
Our device supports long filenames, so we should be able to handle all kinds
of long filenames, also if they use enumeration in the filename.
I appriciate your input.
Best regards,
Rob van Lieshout
ps: we got SD-HC cards working for writing as well now. Not sure how to
commit the changes.....
More information about the En-Nut-Discussion
mailing list