Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
CBuffFileStream/CBuffFileStream.h
/* |
File: CBuffFileStream.h |
Contains: Buffer handling. |
Written by: Tim Carroll |
Copyright: Copyright (c) 1999 Apple Computer, Inc., All Rights Reserved. |
You may incorporate this Apple sample source code into your program(s) without |
restriction. This Apple sample source code has been provided "AS IS" and the |
responsibility for its operation is yours. You are not permitted to redistribute |
this Apple sample source code as "Apple sample source code" after having made |
changes. If you're going to re-distribute the source, we require that you make |
it clear in the source that the code was descended from Apple sample source |
code, but that you've made changes. |
*/ |
#pragma once |
#ifdef __cplusplus |
extern "C" { |
#endif |
enum |
{ |
eBuffFileStreamBufferMaxSize = 4096 |
}; |
enum |
{ |
eBuffFileStreamIamReading, |
eBuffFileStreamIamWriting |
}; |
typedef struct CBuffFileStreamData |
{ |
// This is a buffer which we will slide around as a window into the file |
char mFileWindow[eBuffFileStreamBufferMaxSize]; |
// This is the file ref num of the opened file |
short mFileRefNum; |
// The current length of the buffer. This cannot exceed the maximum size |
unsigned mBufferLength; |
// The offset into the buffer where we are currently reading from |
unsigned mBufferCurPos; |
// The offset into the file where the window begins |
// This is used only to adjust our location when we flush the buffer |
long mWindowLocation; |
// The permissions we have for accessing the file |
// This is determined upon open, however it can change if things |
// change behind our back. |
short mFilePerms; |
// Whether or not the buffer we have is for writing |
int mBufferMode; |
} CBuffFileStreamData; |
OSErr BFSOpenFile(CBuffFileStreamData **newdata, FSSpec *inFileInfo, long inPrivileges); |
OSErr BFSCloseFile(CBuffFileStreamData *fdata); |
OSErr BFSSetMarker(CBuffFileStreamData *fdata, long inOffset, long fromWhere); |
long BFSGetMarker(CBuffFileStreamData *fdata); |
OSErr BFSSetLength(CBuffFileStreamData *fdata, long inLength); |
long BFSGetLength(CBuffFileStreamData *fdata); |
OSErr BFSWrite(CBuffFileStreamData *fdata, long *writeAmt, const void *inBuffer); |
OSErr BFSRead(CBuffFileStreamData *fdata, long *readAmt, void *outBuffer); |
long BFSGetFilePermissions(CBuffFileStreamData *fdata); |
OSErr BFSFlushFile(CBuffFileStreamData *fdata); |
#ifdef __cplusplus |
} |
#endif |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14