View Single Post
Old 15th April 2009
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

Ok, I sorted through the relevant functions and made a little summary. Here it is in case anyone ever finds it helpful. Notes:

* there are many other functions related to file access
* BSD = NetBSD 4.0.1 and OpenBSD 4.4
* Linux = Slackware 11.0 and 12.2
* comments on speed are on my i386 machines (take with grain of salt )
* corrections etc. are welcome

Functions using stdio library interface and FILE structures:

16- and 18-bit, exists in K&R and PDP-7 respectively but not Linux or BSD
seek

32-bit
fseek
ftell

32-bit Linux, can be changed to 64 by a #define.
... also ...
64-bit BSD.

fseeko
ftello - does not show the result of lseek. [Either in 32 or 64 bit mode (Linux)]

fread

Functions using system/kernel calls with file descriptors:

32-bit Linux, can be changed to 64 by a #define.
... also ...
64-bit BSD.

lseek

64-bit Linux
lseek64 = llseek

"ltell" - does not exist, ftell[o] don't work here.

read - faster than fread (Linux, NetBSD); not faster than fread (OpenBSD)

-----------------------------------

At the moment, I think I'll stick with read() over fread(), since it can be faster. A lot of reads are done, and portability to non-Unix-like is not important.

So lseek() must be used so as not to mix functions from the two categories (originally done via blundering).

On Linux lseek() is 32-bit by default, which is good enough for now, and can easily be changed if needed. Not a big downside.

Last edited by IdOp; 15th April 2009 at 03:56 AM. Reason: added 18 bits and attempt to clarify headings
Reply With Quote