Re: [cc65] Atari file i/o functions

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2002-04-23 22:27:06


On Tue, Apr 23, 2002 at 01:08:28PM -0700, Shawn Jefferson wrote:
> Unfortunately, my grasp of assembler is weak.  I've attempted to code the
> ftell function (only implementing seeking from the beginning of the file at
> the moment) but haven't tested it as I don't even know if I can build the
> Atari lib myself or not.

Building the library is no problem if you're using Linux, as most other people
do. Using some other Unix should also work, maybe with some minor glitches. If
you're using something else, you are completely on your own :-)

> Also... looking at the way the functions are layed out.. fseek calls lseek
> in the atari library... and ftell calls lseek as well.  That doesn't seem like
> the best way to do it, since you will want to call lseek with different
> offsets depending on what whence is (SEEK_SET, SEEK_CUR, SEEK_END) and ftell
> would/should just call the CIO with command 38 to get the current file
> position.

Maybe Christian can answer this in more detail, but as far as I understand the
sources, lseek is just a dummy function that returns an error code.

Apart from this, the implementation seems to be correct: lseek as defined by
POSIX returns the current file position as a side effect. This side effect is
used in ftell(), while fseek() is based on the main function of lseek
(positioning the file pointer).

> How tied is the system to calling lseek in this manner for these functions?
> I imagine other platforms are implementing their own versions of lseek and
> changing this might break them.

The Atari is currently the only system that has a working standard file I/O,
so if there were changes, they wouldn't break anything. But as it looks for
me, the current implementation is correct, the only problem is that the (Atari
specific) lseek function is currently not implemented.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2002-04-23 22:27:04 CEST