Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.questions Subject: Re: fopen ( ..., "a" ) --- how does the "a" work? Message-ID: <1989Dec7.130813.4992@virtech.uucp> Date: 7 Dec 89 13:08:13 GMT References: <3250@hub.UUCP> Organization: Virtual Technologies Inc. Lines: 30 In article <3250@hub.UUCP>, 6600pete@hub.UUCP writes: > When one opens a file under *most* flavors of UN*X (I realize this is > the kind of thing that will be system-dependent, though it oughtn't) > with fopen ( ..., "a" ), the file mark is supposed to be moved to EOF > before every write. Now, how is this done? Are there two system calls, > one to move the file mark and one to do the write, or is there one > system call, "append"? If the latter, then this is an easier solution > for a problem I have than figuring out how to do record locking. There exists an append mode for open files where the kernel automatically places all writes at the end of file. This is what fopen(3) will use under unix. Under other os's this will depend upon the capabilities of the os. If the system has an append mode, then it will probably be used. Else If the system has a mechanism to move around a file (like unix lseek()) it will probably be used to move to the end of the file before each write. Else the library could just read data until it came to EOF and then write the data. (Yes, this would be very inefficient) -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+