C (34/178)

From:radiat-r aka Sascha Ploss
Date:13 Jul 2000 at 01:19:23
Subject:Re: ExamineFH() Problems

Hi Nick,

> 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

ok, lets see, you did:

struct FileInfoBlock *file_info;

so you define a pointer to a FileInfoBlock, but currently
it's pointing nowhere, so you need to allocate the memory:

file_info = (struct FileInfoBlock *)
AllocMem(sizeof(struct FileInfoBlock),MEMF_CLEAR);
if (file_info) {...} // you MUST check for success here!

This will reserve the required longword aligned memory, which is
initiated by ExamineFH (and don't forget to Free() it afterwards).

> It is becoming very aggrevating because I have to know the file's size so
> that the correct amount of memory is allocated.

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);

returns the Position, where the Filecursor was before Seek was called.
So this would store the position of the line above and move the Filecursor
back to the beginning of the file. Seek() returns -1 in case of error

Seek() is part of dos.h, and AllocMem() is part of exec.h, so don't forget
to include those.

greetz



radiat-r *AmigaPPC*
Don't try to find the truth,
you won't like it...
www.Feuerwehr-Trogen.de
END_OF_TRANSMISSION

------------------------------------------------------------------------
Visit Law.com for exclusive national and regional content,
online CLE Seminars, Practice Centers, Career Listings and
Expert Witness Directory.
http://click.egroups.com/1/6875/1/_/451227/_/963475684/
------------------------------------------------------------------------