Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_File_Imp Class Reference

Inheritance diagram for CP_File_Imp:

CP_NoCopy CP_NoCopy CP_NoCopy CP_File List of all members.

Public Member Functions

 CP_File_Imp ()
 CP_File_Imp (const CP_FileSystemSpec &inFileSpec)
virtual ~CP_File_Imp ()
void Create (FourCharCode inCreator, FourCharCode inType=kCP_Text_FileType)
void Open (SInt16 inPermissions=CP_E_FilePerm_ReadWrite)
void Close ()
SInt64 Length ()
SInt64 GetPosition () const
SInt64 SetPosition (UInt16 inMode, SInt64 inOffset)
UInt32 ReadData (void *inDataBuffer, UInt32 inDataSize, UInt16 inPositionMode=CP_E_FileSeek_FromCurrent, SInt64 inOffset=0)
UInt32 WriteData (const void *inDataBuffer, UInt32 inDataSize, UInt16 inPositionMode=CP_E_FileSeek_FromCurrent, SInt64 inOffset=0)
bool IsOpen ()
 CP_File_Imp ()
 CP_File_Imp (const CP_FileSystemSpec &inFileSpec)
virtual ~CP_File_Imp ()
void Create (FourCharCode inCreator, FourCharCode inType=kCP_Text_FileType)
void Open (SInt32 inPermissions=CP_E_FilePerm_ReadWrite, bool inOpenResourceFork=true)
SInt16 OpenFork (SInt32 inPermissions, const HFSUniStr255 &inForkName)
void Close ()
CP_FileSystemSpec GetFileSpec ()
OSFileRef GetRefNumber ()
SInt64 Length ()
SInt64 GetPosition () const
SInt64 SetPosition (UInt16 inMode, SInt64 inOffset)
void SetEOF (SInt32 inEOF)
UInt32 ReadData (void *inDataBuffer, UInt32 inDataSize, UInt16 inPositionMode=CP_E_FileSeek_FromCurrent, SInt64 inOffset=0)
UInt32 WriteData (const void *inDataBuffer, UInt32 inDataSize, UInt16 inPositionMode=CP_E_FileSeek_FromCurrent, SInt64 inOffset=0)
void UseResFile ()
bool IsOpen ()
void FlushFork (SInt16 inRefNum)
CP_FileSystemSpec GetFileSpec ()
Constructor / Destructor
 CP_File_Imp ()
 Constructor.
 CP_File_Imp (const CP_FileSystemSpec &inFileSpec)
virtual ~CP_File_Imp ()
 Destructor.

Protected Member Functions

const HFSUniStr255 & GetDataForkName ()
const HFSUniStr255 & GetResourceForkName ()

Protected Attributes

CP_FileSystemSpec fFileSpec
OSFileRef fRefNum
OSFileRef fDataForkRefNum
OSFileRef fResourceForkRefNum

Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_File_Imp::CP_File_Imp  ) 
 

Constructor.

Exceptions:
none 

CP_File_Imp::CP_File_Imp const CP_FileSystemSpec inFileSpec  ) 
 

Constructor. This sets the CP_FileSystemSpec for this file.

Parameters:
inFileSpec CP_FileSystemSpec that specifies the name and location of the platforms file object.

CP_File_Imp::~CP_File_Imp  )  [virtual]
 

Destructor.

CP_File_Imp::CP_File_Imp  ) 
 

CP_File_Imp::CP_File_Imp const CP_FileSystemSpec inFileSpec  ) 
 

virtual CP_File_Imp::~CP_File_Imp  )  [virtual]
 

CP_File_Imp::CP_File_Imp  ) 
 

CP_File_Imp::CP_File_Imp const CP_FileSystemSpec inFileSpec  ) 
 

virtual CP_File_Imp::~CP_File_Imp  )  [virtual]
 


Member Function Documentation

void CP_File_Imp::Create FourCharCode  inCreator,
FourCharCode  inType = kCP_Text_FileType
 

Creates the platforms file object in the platforms file system. Throws an OSError if there is a problem creating the file.

Parameters:
inCreator The creator code for this file.
inType The file type code for this file.
Returns:
void

void CP_File_Imp::Open SInt16  inPermissions = CP_E_FilePerm_ReadWrite  ) 
 

Opens the file for reading and/or writing depending on the passed in inPermissions. Throws an OSError if there is a problem opening the data fork. Throws a std::logic_error if the file is already open.

Parameters:
inPermissions Permissions for accessing the file. It should be one of the following values:
  • CP_E_FilePerm__ReadOnly
  • CP_E_FilePerm__WriteOnly
  • CP_E_FilePerm__ReadWrite
  • CP_E_FilePerm__ReadWriteShared
Returns:
void

void CP_File_Imp::Close  ) 
 

Closes the file in the platforms file system.

Returns:
void

SInt64 CP_File_Imp::Length  ) 
 

Returns the length of our file. The file needs to currently be open, otherwide an error occurs.

Exceptions:
OSStatus exceptions
Returns:
SInt64 Length of the file.

SInt64 CP_File_Imp::GetPosition  )  const
 

Returns the current file marker position in the file.

Exceptions:
OSStatus exceptions
Returns:
SInt64 Returns the currennt position in the file.

SInt64 CP_File_Imp::SetPosition UInt16  inMode,
SInt64  inOffset
 

Sets the current position in the file based on the passed in parameters.

Parameters:
inPositionMode Specifier for where in the file to set the position. It should be one of the following: -CP_E_FileSeek__FromBegin -CP_E_FileSeek__FromEnd -CP_E_FileSeek__FromCurrent
inOffset Number of bytes offset from the position mode parameter to set the positionn.
Exceptions:
OSStatus exceptions
Returns:
SInt32 Returns the new position in the file.

UInt32 CP_File_Imp::ReadData void *  inDataBuffer,
UInt32  inDataSize,
UInt16  inPositionMode = CP_E_FileSeek_FromCurrent,
SInt64  inOffset = 0
 

Reads data fromm the file. Throws an OSError if there was a problem.

Parameters:
inDataBuffer Pointer to the buffer that holds the data to be read into.
inDataSize Number of bytes to read into the passed in data buffer.
inPositionMode Specifier for where in the file to start reading. It should be one of the following: -CP_E_FileSeek__FromBegin -CP_E_FileSeek__FromEnd -CP_E_FileSeek__FromCurrent
inOffset Number of bytes offset from the position mode parameter to begin writing.
Exceptions:
OSStatus exceptions
Returns:
UInt32 Actual number of bytes read.

UInt32 CP_File_Imp::WriteData const void *  inDataBuffer,
UInt32  inDataSize,
UInt16  inPositionMode = CP_E_FileSeek_FromCurrent,
SInt64  inOffset = 0
 

Writes data to the file. Throws an OSError if there was a problem.

Parameters:
inDataBuffer Pointer to the buffer that holds the data to be written.
inDataSize Number of bytes to write from the passed in data buffer.
inPositionMode Specifier for where in the file to start writing. It should be one of the following: CP_E_FileSeek__FromBegin CP_E_FileSeek__FromEnd CP_E_FileSeek__FromCurrent
inOffset Number of bytes offset from the position mode parameter to begin writing.
Returns:
UInt32 Actual number of bytes written.

bool CP_File_Imp::IsOpen  ) 
 

void CP_File_Imp::Create FourCharCode  inCreator,
FourCharCode  inType = kCP_Text_FileType
 

void CP_File_Imp::Open SInt32  inPermissions = CP_E_FilePerm_ReadWrite,
bool  inOpenResourceFork = true
 

Opens the file for reading and/or writing depending on the passed in inPermissions. Throws an OSError if there is a problem opening the data fork. Throws a std::logic_error if the file is already open.

Note: If the file is being opened for write access, and the file doesn't currently exist, it will be created, and then opened to match the behavior of Windows.

Parameters:
inPermissions Permissions for accessing the file. It should be one of the following values:
  • CP_E_FilePerm__ReadOnly
  • CP_E_FilePerm__WriteOnly
  • CP_E_FilePerm__ReadWrite
  • CP_E_FilePerm__ReadWriteShared
inOpenResourceFork Flag to indicate if we should also open the resource fork, default is true.
Exceptions:
Throws a std::logic_error if the file is already open, otherwise OSStatus exceptions on errors.
Returns:
void

SInt16 CP_File_Imp::OpenFork SInt32  inPermissions,
const HFSUniStr255 &  inForkName
 

void CP_File_Imp::Close  ) 
 

CP_FileSystemSpec CP_File_Imp::GetFileSpec  ) 
 

OSFileRef CP_File_Imp::GetRefNumber  ) 
 

SInt64 CP_File_Imp::Length  ) 
 

SInt64 CP_File_Imp::GetPosition  )  const
 

SInt64 CP_File_Imp::SetPosition UInt16  inMode,
SInt64  inOffset
 

void CP_File_Imp::SetEOF SInt32  inEOF  ) 
 

UInt32 CP_File_Imp::ReadData void *  inDataBuffer,
UInt32  inDataSize,
UInt16  inPositionMode = CP_E_FileSeek_FromCurrent,
SInt64  inOffset = 0
 

UInt32 CP_File_Imp::WriteData const void *  inDataBuffer,
UInt32  inDataSize,
UInt16  inPositionMode = CP_E_FileSeek_FromCurrent,
SInt64  inOffset = 0
 

void CP_File_Imp::UseResFile  ) 
 

void CP_File_Imp::SetFileSpec const CP_FileSystemSpec inFileSpec  ) 
 

bool CP_File_Imp::IsOpen  ) 
 

void CP_File_Imp::FlushFork SInt16  inRefNum  ) 
 

const HFSUniStr255 & CP_File_Imp::GetDataForkName  )  [protected]
 

Returns the MacOS name of the data fork. Throws an OSError if there is a problem getting the forks name.

Exceptions:
OSStatus exceptions
Returns:
HFSUniStr255 MacOS name of the data fork.

const HFSUniStr255 & CP_File_Imp::GetResourceForkName  )  [protected]
 

Returns the MacOS name of the resource fork. Throws an OSError if there is a problem getting the forks name.

Exceptions:
OSStatus exceptions
Returns:
HFSUniStr255 MacOS name of the resource fork.

void CP_File_Imp::Create FourCharCode  inCreator,
FourCharCode  inType = kCP_Text_FileType
 

void CP_File_Imp::Open SInt32  inPermissions = CP_E_FilePerm_ReadWrite  ) 
 

Opens the file for reading and/or writing depending on the passed in inPermissions. Throws an OSError if there is a problem opening the data fork. Throws a std::logic_error if the file is already open.

Parameters:
inPermissions Permissions for accessing the file. It should be one of the following values:
  • CP_E_FilePerm__ReadOnly
  • CP_E_FilePerm__WriteOnly
  • CP_E_FilePerm__ReadWrite
  • CP_E_FilePerm__ReadWriteShared
Exceptions:
none 
Returns:
void

void CP_File_Imp::Close  ) 
 

CP_FileSystemSpec CP_File_Imp::GetFileSpec  ) 
 

SInt64 CP_File_Imp::Length  ) 
 

SInt64 CP_File_Imp::GetPosition  )  const
 

SInt64 CP_File_Imp::SetPosition UInt16  inMode,
SInt64  inOffset
 

void CP_File_Imp::SetEOF SInt32  inEOF  ) 
 

UInt32 CP_File_Imp::ReadData void *  inDataBuffer,
UInt32  inDataSize,
UInt16  inPositionMode = CP_E_FileSeek_FromCurrent,
SInt64  inOffset = 0
 

UInt32 CP_File_Imp::WriteData const void *  inDataBuffer,
UInt32  inDataSize,
UInt16  inPositionMode = CP_E_FileSeek_FromCurrent,
SInt64  inOffset = 0
 

void CP_File_Imp::SetFileSpec const CP_FileSystemSpec inFileSpec  ) 
 

bool CP_File_Imp::IsOpen  ) 
 


Member Data Documentation

CP_FileSystemSpec CP_File_Imp::fFileSpec [protected]
 

OSFileRef CP_File_Imp::fRefNum [protected]
 

CP_FileSystemSpec containing the name and location of this file.

OSFileRef CP_File_Imp::fDataForkRefNum [protected]
 

CP_FileSystemSpec containing the name and location of this file.

OSFileRef CP_File_Imp::fResourceForkRefNum [protected]
 

MacOS file reference number for file when open, Data fork.


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:01:40 2005 for CPLAT by  doxygen 1.4.0