PBGetFPosSync
PBGetFPos Query current position of an open file's file mark
#include <Files.h> File Manager (PBxxx)
OSErr PBGetFPos(pb, async );
ParmBlkPtr pb ; address of a 50-byte IOParam structure
Boolean async ; 0=await completion; 1=immediate return
returns Error Code; 0=no error
PBGetFPos obtains the current value of an open file's mark.
pb is the address of a 50-byte IOParam structure. The relevant fields
are:
Out-In Name Type Size Offset Description
-> ioCompletion ProcPtr 4 12 Completion routine address (if async =TRUE)
-> ioRefNum short 2 24 File reference number
<- ioResult OSErr 2 16 Error Code (0=no error, 1=not done yet)
<- ioReqCount long 4 36 Gets set to 0
<- ioActCount long 4 40 Gets set to 0
<- ioPosMode short 2 44 Gets set to 0
<- ioPosOffset long 4 46 Receives file mark (bytes from start of file)
async is a Boolean value. Use FALSE for normal (synchronous) operation
or TRUE to enqueue the request and resume control immediately. See
Async I/O.
Returns: an operating system Error Code. It will be one of:
noErr (0) No error
fnOpnErr (-38) File not open
gfpErr (-52) Get file position error
ioErr (-36) I/O error
rfNumErr (-51) Bad ioRefNum

Notes: After each read or write operation, the current file position is returned in
ioPosOffset; so PBGetFPos may not be needed often.
If you follow this call with a call to PBGetEOF, you can compare ioMisc to
ioPosOffset to see if you are at the end-of-file.