Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Files /
Chapter 2 - File Manager / File Manager Reference
High-Level File Access Routines / Reading, Writing, and Closing Files


FSWrite

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;
refNum
The file reference number of an open file.
count
On input, the number of bytes to write to the file; on output, the number of bytes actually written.
buffPtr
A pointer to the data buffer from which the bytes are to be written.
DESCRIPTION
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.

Note
The low-level PBWrite function lets you set the mark without having to call SetFPos.
RESULT CODES
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