TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Winston van Oosterhout
from: Mike Bilow
date: 1995-03-18 22:08:38
subject: ANSI C vs. API calls

Winston van Oosterhout wrote in a message to All:

 WvO> There are several API calls available that seem to do the
 WvO> same thing as standard ANSI C functions, like open() vs.
 WvO> DosOpen(), mkdir() vs. DosCreateDir() and a whole bunch more
 WvO> that are related to file I/O.
 WvO> Is there any difference in code efficiency, EXE size and
 WvO> speed when the OS/2 API calls are used?

You lose portability but gain finer control by going directly to the
operating system.  For example, DosOpen() allows you to warn the file
system about expected locality of access, whether the file will be accessed
sequentially or randomly.  Sometimes you can get the best of both worlds,
as with calling DosOpen() to get a file handle, calling fdopen() (if
supported by your compiler) to associate a FILE stream with that handle,
and then using the usual fread() and fwrite() calls.

 WvO> Take mkdir() as an example. I don't need to set EA's when
 WvO> creating a particular directory, so I could be using both
 WvO> mkdir() and DosCreateDir(). I already make use of a lot
 WvO> other Control Program calls like DosSetPriority(), if that
 WvO> would make a difference. And the code doesn't have to be
 WvO> portable to other operating systems.

Eventually, fopen() gets translated somehow to DosOpen().  If portability
is irrelevant and you don't need any special features beyond those of
fopen(), I would probably choose to use fopen() on the ground that it was
easier.
 
-- Mike


---
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 105/42 620/243 624/50 711/401 409 410 413 430 807 808 809 934 955
SEEN-BY: 712/407 515 628 704 713/888 800/1 7877/2809
@PATH: 323/107 150 3615/50 396/1 270/101 105/103 42 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.