Amiga-C (30/223)

From:Alexander Niven-Jenkins
Date:10 Aug 2001 at 19:19:57
Subject:[amiga-c] Re: ExamineFH

Hiya Twelvebullets,

On 10-Aug-01, Twelvebullets wrote:

> When I get to ExamineFH, it fails ! Why ??

Firstly you need to allocate the memory for "fibb" as you have just
declared a pointer; secondly most of the OS dos routines need aligned data
so you need to allocate it with something like AllocVec(). See a quick
example below.

// returns the size of a file, -1 on error
long FileSize(char *filename)
{
long filesize = -1, handle = NULL;
struct FileInfoBlock *fib = NULL;

if(handle = Open(filename, MODE_OLDFILE))
{
fib = (struct FileInfoBlock*)AllocVec(sizeof(struct FileInfoBlock),
MEMF_PUBLIC);
if(fib)
{
ExamineFH(handle, fib);
filesize = fib->fib_Size;
FreeVec(fib);
}
Close(handle);
handle = NULL;
}
return filesize;
}

Kind regards...

Alex



Cremlin Software - http://www.cremlinsoftware.org
Founder, lead programmer - mailto:ghandi@cremlinsoftware.org
Production, programmer - mailto:anj@cremlinsoftware.org

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Small business owners...
Tell us what you think!
http://us.click.yahoo.com/vO1FAB/txzCAA/ySSFAA/dpFolB/TM
---------------------------------------------------------------------~->

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/