🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #4659

Re: Wanted: Filelength() function

#4659
From: Randell Jesup
Date: Thu, 02 Aug 1990 01:35
26 lines
1511 bytes
In article <2671@mindlink.UUCP> a665@mindlink.UUCP (Anthon Pang) writes:
>I don't think there's a function that returns the filelength of a file, with
>AmigaDOS.  But I need an equivalent...how do you determine the length of a file
>given only the file handle (eg from an Open)?  There must be a way to find the
>associated file lock, as one is created when the file is opened (shared /
>exclusive)...right?  Then you can Examine the FileInfoBlock and get the file's
>length from the fibSize field.
>
>    ie    size_t  filelength(int handle)
>
>I want a function that doesn't require knowing the filename...or do I need 2.0?

	Well, to do it simply requires 2.0 (which has ExamineFH).  Under
< 2.0, use this:

	...
	oldpos = Seek(fh,0L,OFFSET_END);
	size = Seek(fh,oldpos,OFFSET_BEGINNING);
	...

	In other words, seek to the end and see where that is.

-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com  BIX: rjesup  
Common phrase heard at Amiga Devcon '89: "It's in there!"
Technical Details
Message-ID: <13570@cbmvax.commodore.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!usc!apple!oliveb!amiga!cbmvax!jesup
References: <2671@mindlink.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!usc!apple!oliveb!amiga!cbmvax!jesup
From: jesup@cbmvax.commodore.com (Randell Jesup)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Wanted: Filelength() function
Message-ID: <13570@cbmvax.commodore.com>
Date: 2 Aug 90 01:35:20 GMT
References: <2671@mindlink.UUCP>
Reply-To: jesup@cbmvax (Randell Jesup)
Organization: Commodore, West Chester, PA
Lines: 26