🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #29184

Re: FILE I/O

#29184
From: Matthew R. Singer
Date: Fri, 13 Nov 1987 12:09
32 lines
1531 bytes
In article <12361@felix.UUCP>, preston@felix.UUCP (Preston Bannister) writes:
> 
> There is a much simpler way to find the length of a file.  You simply
> do an Fseek to the end of the file.  This means of getting the length
> of a file is also usable with Unix and MSDOS (if not always necessary).
> (I'm doing this from memory):
> 
> void
> Example (filename)
>   char *filename;
> {
>   int f, length;
>   f = Fopen(name,0);
>   if (f > 0)
>   {
>     length = Fseek(f,0,2);	/* seek to end of file */
>     Fseek(f,0,0);		/* seek back to beginning of file */
>     /* we now know the size of the file */
>     ProcessFile(f,length);	/* for instance */
>     Fclose(f);
>   }
> }
> --
> Preston L. Bannister

This is a VERY slow way to do it. Especially on LARGE files where
the seek is worse than the open.

Why not just use Fsfirst and read the file size out of the DTA?
This works on both Gemdos and MSdos.

Matt Singer
Technical Details
Message-ID: <800@xn.LL.MIT.EDU>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!hao!ames!ll-xn!singer
References: <2023@homxc.UUCP> <183@decvax.UUCP> <12361@felix.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!husc6!hao!ames!ll-xn!singer
From: singer@XN.LL.MIT.EDU (Matthew R. Singer)
Newsgroups: comp.sys.atari.st
Subject: Re: FILE I/O
Message-ID: <800@xn.LL.MIT.EDU>
Date: Fri, 13-Nov-87 07:09:38 EST
Article-I.D.: xn.800
Posted: Fri Nov 13 07:09:38 1987
Date-Received: Sun, 15-Nov-87 07:39:35 EST
References: <2023@homxc.UUCP> <183@decvax.UUCP> <12361@felix.UUCP>
Organization: MIT Lincoln Laboratory, Lexington, MA
Lines: 32
Keywords: Mark Williams C, Fseek, fseek
Summary: File size