#Finding file size
3 messages in this thread
I am writting a program that is started from WB and takes other file
icons as input from the extended select option. What I want to do is
find out the size of each of these file arguments. I don't want to
use an AmigaDos command nor do I want to open the file – go to the
end – and check file pointer posistion.
I have looked and looked and all that I can find on this is the
FileInfoBlock structure. From the little that is written I have setup
a memory slot for the structure, then called AllocDosObject(), the
Examine(), and finally looked for the size. I can't get things to
work. I think the problem is with the Alloc— function. I don't
think I'm setting it up correctly.
Can someone give me an example? Also, everything here is part of the dos
library. I can find almost nothing about this library. It's not in the
RKMs nor on any instruction disk I have. Where can I get something on
dos.library with examples on doing things with it.
-Tom
Tom,
Here's a bit of code I use to get the size of a file…
long fsize(char *file)
{
struct FileInfoBlock __aligned FBlock;
BPTR FLock;
if(!(FLock = Lock(file,ACCESS_READ))) /* try to lock file */
return NULL;
if(!Examine(FLock,&FBlock))
{
UnLock(FLock);
return NULL;
}
UnLock(FLock);
return(FBlock.fib_Size);
}
.. note that the FileInfoBlock structure must be aligned (or could be
obtained by AllocMem()). Note also that you may already have the Lock you
need, so you might could just do the Examine(). I'm not sure what you mean
by "I don't want to use an AmigaDOS command"… the information about the
file _has_ to come from AmigaDOS (or did you mean not wanting to execute a
C: command?).
Anyway, hope this helps…
– Keith
Tom
>>>Also, everything here is part of the dos library. I can find almost
nothing about this library. It's not in the RKMs nor on any instruction
disk I have. Where can I get something on dos.library with examples on
doing things with it.<<<
You want "The AmigaDOS Manual" from Bantam books, (3rd Edition). ISBN
0-553-35403-5 Its extremely hard to get hold of (in the U.K.) so have fun
🙂
Nev.