Previous Book Contents Book Index Next

Inside Macintosh: Files /
Chapter 1 - Introduction to File Management / File Management Reference
File Access Routines / Reading, Writing, and Closing Files


You can use the FSWrite function to write any number of bytes to an open file.

FUNCTION FSWrite (refNum: Integer; VAR count: LongInt; 
                  buffPtr: Ptr): OSErr;
The file reference number of an open file.
On input, the number of bytes to write to the file; on output, the number of bytes actually written.
A pointer to the data buffer from which the bytes are to be written.
The FSWrite function takes the specified number of bytes from the specified data buffer and attempts to write them to the specified file. Because the write operation begins at the current mark, you might want to set the mark first by calling the SetFPos function.

If the write operation completes successfully, FSWrite moves the file mark to the
byte following the last byte written and returns noErr. If you try to write past the
logical end-of-file, FSWrite moves the logical end-of-file. If you try to write past
the physical end-of-file, FSWrite adds one or more clumps to the file and moves the physical end-of-file accordingly.

noErr0No error
dskFulErr-34Disk full
ioErr-36I/O error
fnOpnErr-38File not open
posErr -40Attempt to position mark before start of file
wPrErr -44Hardware volume lock
fLckdErr-45File is locked
vLckdErr -46Software volume lock
paramErr-50Negative count
rfNumErr-51Bad reference number
wrPermErr-61Read/write permission doesn't allow writing

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996