Rockbox

Tasklist

FS#5736 - Correctly handle files with long names containing non-latin characters

Attached to Project: Rockbox
Opened by Alexander Levin (fml2) - Saturday, 29 July 2006, 17:21 GMT
Task Type Patches
Category Drivers
Status Closed
Assigned To No-one
Operating System All players
Severity High
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Correctly handle files with long names containing non-latin characters (more precisely: files whose names, when utf8 encoded, require more than 255 bytes). This avoids player freeze when such files are present in the file system.

The patch does the following. When reading a entry for a file with long name, the name is first utf8-decoded into a temporary buffer. Then the check is made whether the content of the buffer would fit into the dir entry. If not, the long name is ignored and the short DOS name (which is OEM encoded) is used instead.

Beware: If this short name contains characters from the upper half of the code page, that name may appear with strange glyphs or empty character in the file browser. This is because Unicode characters 0x80 to 0x9F are control characters. They can't be displayed.
This task depends upon

Closed by  Rani Hod (RaeNye)
Monday, 31 July 2006, 23:00 GMT
Reason for closing:  Accepted
Additional comments about closing:  P.S.
Please use spaces instead of tabs in RB code.
Comment by Rani Hod (RaeNye) - Saturday, 29 July 2006, 17:35 GMT
1. Please use diff -u next time.
2. Please avoid submitting only-whitespace changes.

The fixed patch is attached, later I'll actually compile it.
Comment by Rani Hod (RaeNye) - Saturday, 29 July 2006, 20:24 GMT
I created a bad long file name that crashed the sim when viewing it, but the patch didn't solve it.
Please check it on your sim.
Comment by Alexander Levin (fml2) - Saturday, 29 July 2006, 23:44 GMT
Sorry for the whitespace changes. My editor stripped trailing spaces when files were saved. I changed the editor configuration.

To the problem: is fat.c used in simulator builds? I haven't found fat.o in the sim build directory. In the normal (=not sim) build fat.o is present (in firmware/drivers). So the patch may have no effect in the sim build.
Comment by Alexander Levin (fml2) - Sunday, 30 July 2006, 09:36 GMT
A better version of the patch: requires significantly less stack space. Also the padding FAT characters are handled correctly. Works well for me (iriver H1xx).
Comment by Linus Nielsen Feltzing (linusnielsen) - Sunday, 30 July 2006, 10:46 GMT
I like it. One small thing: please try to keep the source code lines shorter than 80 characters.
Comment by Alexander Levin (fml2) - Sunday, 30 July 2006, 11:55 GMT
> One small thing: please try to keep the source code lines shorter than 80 characters.

Ok, I will in the future. I won't correct this patch since there are many lines longer than 80 chars in fat.c anyway.
Comment by Rani Hod (RaeNye) - Monday, 31 July 2006, 19:10 GMT
I'm ready to commit this patch;
I need your real name to do so.
Comment by Alexander Levin (fml2) - Monday, 31 July 2006, 21:51 GMT
Here is a slightly improved patch (yet better handling of long name padding; made the function static)

My name is Alexander Levin

Loading...