From: Philip Wright on
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 :)
--
Posted via http://www.ruby-forum.com/.

From: Joseph E. Savard on
This may work for you.

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

Read the comments too..


> From: Philip Wright <sulligogs(a)hotmail.com>
> Reply-To: <ruby-talk(a)ruby-lang.org>
> Newsgroups: comp.lang.ruby
> Date: Tue, 20 Jul 2010 16:54:59 +0900
> To: ruby-talk ML <ruby-talk(a)ruby-lang.org>
> Subject: 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 :)
> --
> Posted via http://www.ruby-forum.com/.
>


From: Philip Bright on
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.
--
Posted via http://www.ruby-forum.com/.

From: Joseph E. Savard on
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 http://ruby-doc.org/core/classes/IO.html. Does not seem to
hit the "DIRECTORY" (FAT) structure...

Interesting link: http://tronweb.super-nova.co.jp/t-enginefataccess.html

> From: Philip Bright <sulligogs(a)hotmail.com>
> Reply-To: <ruby-talk(a)ruby-lang.org>
> Newsgroups: comp.lang.ruby
> Date: Wed, 21 Jul 2010 03:01:16 +0900
> To: ruby-talk ML <ruby-talk(a)ruby-lang.org>
> Subject: Re: Editing a FAT/FAT32 Partition Table
>
> 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.
> --
> Posted via http://www.ruby-forum.com/.
>


From: David Masover on
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 http://ruby-doc.org/core/classes/IO.html. 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/