From: | Alexander Niven-Jenkins |
Date: | 13 Jul 2000 at 18:19:26 |
Subject: | Re: ExamineFH() Problems |
Hiya radiat-r,
On 13-Jul-00, you wrote:
>> I understand that the FileInfoBlock structure has to be longword aligned
>> and I think this is where my problem lies; however - i don't know how to
// returns the size of a file, -1 on error
long FileSize( char *filename )
{
long filesize = -1, filehandle = NULL;
struct FileInfoBlock *fib = NULL;
if( filehandle = Open( filename, MODE_OLDFILE ) )
{
if( fib = ( struct FileInfoBlock* )AllocVec( sizeof( struct
FileInfoBlock ), MEMF_PUBLIC ) )
{
ExamineFH( filehandle, fib );
filesize = fib->fib_Size;
FreeVec( fib );
}
Close( filehandle );
filehandle = NULL;
}
return filesize;
}
The above is what I use, works like a charm. I use AllocVec rather than
AllocDosObject, don't ask me why :-)
> If you just need the size of the file you also can do it another way.
> As you already opened the file, just Seek() to the end to get the position
> of the last byte, which also represents the size of the file. Looks like
> this:
> Seek(fh, 0, OFFSET_END) // move to end of file
> file_size=Seek(fh, 0, OFFSET_BEGINNING);
Don't do this :-) Although it looks a nice idea, try it on a 750mb CD
image file :-)
Kind regards...
Alex
------------------------------------------------------------------------
Wish you had something rad to add to your email?
We do at www.supersig.com.
http://click.egroups.com/1/6807/1/_/451227/_/963510227/
------------------------------------------------------------------------