🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: forcing a flush w/ AmigaDos I/O

#14151
From: Deven T. Corzine
Date: Sat, 10 Mar 1990 03:59
61 lines
3238 bytes
On 2 Mar 90 14:50:49 GMT, koren@hpfelg.HP.COM (Steve Koren) said:

Steve> One more for the AmigaDos I/O gurus:

Steve> How can I tell whether I have reached eof without actually
Steve> reading anything from the file?  That is, I am aware that if
Steve> Read() returns <= 0 when you asked for a positive number of
Steve> byte, you either hit the end of the file or had an error.  But
Steve> what if (for a reason that is not important here - you'll have
Steve> to trust me that it's necessary) I have a file pointer but
Steve> don't want to call Read() to check eof status?  I can't seem to
Steve> find an Feof() call for AmigaDos I/O.

Hmm.  I'll give this a shot.

Eof(fh)
BPTR fh;
{
   ULONG pos;

   pos = Seek(fh, 0L, OFFSET_END);
   return(pos==Seek(fh, pos, OFFSET_BEGINNING));
}

While this should work reliably on _regular_ files, I suggest you
don't try it on a pipe or interactive input.  Furthermore, this may be
quite slow, depending on what the actual implementation of Seek() is
like.  If you call this function frequently, you're inviting disk
thrashing.  There's probably a better way to do this, but maybe not
with the DOS calls available.  The only other option to try with Seek
might be to change that first Seek to Seek(fh,1L,OFFSET_CURRENT) and
check for an error representing seeking beyond the end of the file.

Steve> [ ... switching to AmigaDOS I/O for speed ...]
Steve> I've found a few capabilities that I need but can't find, such
Steve> as this and the Fflush() call.  Any help would be greatly
Steve> appreciated!

As I've said, forget about FFlush(); Write() will block until done.  I
don't see what you need an feof() type of function for.  Maybe if you
could explain in more detail what you're attempting, I could offer an
alternative approach to try which wouldn't need an feof()...

Steve> PPPS - So far, empirical results seem to suggest that the
Steve> AmigaDos Read() call is from 5 to 10 times faster than the
Steve> Lattice read() call.  A file which used to take 17 seconds to
Steve> 'wc -c' now takes 2 seconds with the SKsh 1.4 wc command.  I
Steve> wonder how the Lattice call is implemented?

It's an interesting question.  I don't see that they NEED to do
anything beyond a table lookup on fd for a filehandle, and then simply
call the AmigaDOS Read() routine.  But I haven't looked at their
implementationaybe there's something I've missed.

Deven
-- 
Deven T. Corzine        Internet:  deven@rpi.edu, shadow@pawl.rpi.edu
Snail:  2151 12th St. Apt. 4, Troy, NY 12180   Phone:  (518) 274-0327
Bitnet:  deven@rpitsmts, userfxb6@rpitsmts     UUCP:  uunet!rpi!deven
Simple things should be simple and complex things should be possible.
Technical Details
Message-ID: <DEVEN.90Mar9225937@netserv2.rpi.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!crdgw1!rpi!netserv2!deven
References: <13920051@hpfelg.HP.COM> <13920053@hpfelg.HP.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!crdgw1!rpi!netserv2!deven
From: deven@rpi.edu (Deven T. Corzine)
Newsgroups: comp.sys.amiga.tech
Subject: Re: forcing a flush w/ AmigaDos I/O
Message-ID: <DEVEN.90Mar9225937@netserv2.rpi.edu>
Date: 10 Mar 90 03:59:33 GMT
References: <13920051@hpfelg.HP.COM> <13920053@hpfelg.HP.COM>
Organization: Rensselaer Polytechnic Institute, Troy, NY
Lines: 61
In-Reply-To: koren@hpfelg.HP.COM's message of 2 Mar 90 14:50:49 GMT