Editing a FAT/FAT32 Partition Table

Hi,

I’m starting a little project for myself which basically involves
reorganising the entries in a FAT/FAT32 table. My reason is simple. I
have a car stereo that reads SD cards, but will only play the songs in
the order that they appear in the file allocation table.

I know I should buy a better car stereo, but I’ve got a bit of time on
my hands right now and would like to see this through.

So, could anyone tell me how to access the entries in a FAT directly
with Ruby? Maybe C or C++ is better, but I haven’t used those in ages
and do not want to spend half a day pulling my hair out just relearning
the syntax.

Thank you all in advance :slight_smile:

This may work for you.

http://hem.passagen.se/chsw/fatsort/index.html

Read the comments too…

Very fast. Thanks for the heads up.

Not sure which language he used. I have sent the author an email asking
for any help he may give.

I take it then Ruby is limited in this area?

Many thanks.

Not sure I can committ to Ruby being limited in this area. Just know
how to
do it in C/c++ from my experience…

Take a look here class IO - RDoc Documentation. Does not
seem to
hit the “DIRECTORY” (FAT) structure…

Interesting link: Accessing a FAT File System from T-Engine

On Tuesday, July 20, 2010 01:26:28 pm Joseph E. Savard wrote:

Not sure I can committ to Ruby being limited in this area. Just know how
to do it in C/c++ from my experience…

Take a look here class IO - RDoc Documentation. Does not seem
to hit the “DIRECTORY” (FAT) structure…

Doesn’t seem like it could, really. I don’t know of any filesystem API
which
would make this clean.

One possible hack would be to move the files all to a temporary
directory on
the same device, then move them back, one at a time, syncing after each
move.
That might force the directory order, but it might wear your SD card a
bit,
and I don’t know enough about FAT to know whether it’d do what you’re
asking.

If that doesn’t work, you’re going to need some sort of low-level access
(/dev/whatever on Unix) and a lot of binary manipulation (or a library).
I
don’t know that there’s anything for Ruby – maybe this in JRuby:

http://code.google.com/p/fat32-lib/