writing a utility for format a file
Hi,
I am trying to write a utility for formating a file of 1 Mbyte to be used as a disk in an OS simulater so that I can have my file system running on it. I am trying to use a bitmap to manage the free blocks on the disk. How can I write a bitmap, in reality an array of bits to my file and than read from that file in another program. Trying for days but no luck. Hope some one has done something like writing a format utility and file system stuff so they can better explain me this.
Thank you
Re: writing a utility for format a file
Quote:
Originally posted by powinda
How can I write a bitmap, in reality an array of bits to my file and than read from that file in another program.
Code:
struct os_bitmap
{
unsigned char array[SIZE];
};
FILE * mydisk = fopen( "mydisk", "w" );
fwrite( &my_os_bitmap, sizeof struct os_bitmap, 1, mydisk );
Vola!
Reading is naturally done in the same way. It's up to you to provide implementation / toggling of specific bits / making it actually mean something.
Quzah.