Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: srg86 on May 03, 2005, 07:36:50 PM

Title: The size of a file
Post by: srg86 on May 03, 2005, 07:36:50 PM
Hi

How do I find out the size of a file is using AmigaDOS calls (I don't think there is anything to do this in the standard C library but I could be wrong).

thanks
srg
Title: Re: The size of a file
Post by: Piru on May 03, 2005, 07:59:48 PM
dos.library/Examine
dos.library/ExamineFH

Occasionally also code using dos.library/Seek can be seen, but this method is really really slow with FFS and large files, and should be avoided.
Title: Re: The size of a file
Post by: Fats on May 03, 2005, 07:59:57 PM
You can do it in ANSI-C on an open file like this:

fseek(f, 0, SEEK_END);
size = ftell(f);


the conversion to Amiga function calls I leave as an exercise :-)

greets,
Staf.
Title: Re: The size of a file
Post by: Piru on May 03, 2005, 08:03:05 PM
@Fats

...which is really slow with FFS and large files. Should be avoided.

If you don't need ANSI-C, use fstat (or stat). Even SAS/C linklibs have it.
Title: Re: The size of a file
Post by: srg86 on May 03, 2005, 09:09:53 PM
I've found Examine, but I can't find what header file ExamineFH is in.

srg
Title: Re: The size of a file
Post by: Doobrey on May 03, 2005, 11:31:13 PM
It`s in dos.h , the same as Examine ;)
Title: Re: The size of a file
Post by: srg86 on May 04, 2005, 02:08:57 PM
doh!!!!!!!!!

srg

P.S. doh!!!!!