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

CP_File Class Reference

A class for representing a platforms file object. More...

Inheritance diagram for CP_File:

CP_File_Imp CP_NoCopy CP_NoCopy CP_NoCopy List of all members.

Public Member Functions

void Create (FourCharCode inCreator, FourCharCode inType=kCP_Text_FileType)
void Create (FourCharCode inCreator, FourCharCode inType=kCP_Text_FileType)
void Open (SInt16 inPermissions=CP_E_FilePerm_ReadWrite)
void Open (SInt32 inPermissions=CP_E_FilePerm_ReadWrite, bool inOpenResourceFork=true)
void Close ()
void Close ()
SInt64 Length ()
SInt64 Length ()
SInt64 GetPosition () const
SInt64 GetPosition () const
SInt64 SetPosition (UInt16 inMode, SInt64 inOffset)
SInt64 SetPosition (UInt16 inMode, SInt64 inOffset)
UInt32 ReadData (void *inDataBuffer, UInt32 inDataSize, UInt16 inPositionMode=CP_E_FileSeek_FromCurrent, SInt64 inOffset=0)
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)
UInt32 WriteData (const void *inDataBuffer, UInt32 inDataSize, UInt16 inPositionMode=CP_E_FileSeek_FromCurrent, SInt64 inOffset=0)
bool IsOpen ()
bool IsOpen ()
SInt16 OpenFork (SInt32 inPermissions, const HFSUniStr255 &inForkName)
CP_FileSystemSpec GetFileSpec ()
CP_FileSystemSpec GetFileSpec ()
OSFileRef GetRefNumber ()
void SetEOF (SInt32 inEOF)
void UseResFile ()
void FlushFork (SInt16 inRefNum)
Constructor / Destructor
 CP_File ()
 Constructor.
 CP_File (const CP_FileSystemSpec &inFileSpec)
virtual ~CP_File ()
 Destructor.
Creation
void Create (FourCharCode inCreator, FourCharCode inType=kCP_Text_FileType)
Open / Close
void Open (SInt32 inPermissions=CP_E_FilePerm_ReadWrite)
void Close ()
Length
SInt64 Length ()
Position
SInt64 GetPosition () const
SInt64 SetPosition (UInt16 inMode, SInt64 inOffset)
void SetEOF (SInt32 inEOF)
Read / Write
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)
Testers
bool IsOpen ()
Setters
void SetFileSpec (const CP_FileSystemSpec &inFileSpec)
Setters
void SetFileSpec (const CP_FileSystemSpec &inFileSpec)
Setters
void SetFileSpec (const CP_FileSystemSpec &inFileSpec)
Creation
void Create (FourCharCode inCreator, FourCharCode inType=kCP_Text_FileType)
Open / Close
void Open (SInt32 inPermissions=CP_E_FilePerm_ReadWrite)
void Close ()
Length
SInt64 Length ()
Position
SInt64 GetPosition () const
SInt64 SetPosition (UInt16 inMode, SInt64 inOffset)
void SetEOF (SInt32 inEOF)
Read / Write
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)
Setters
void SetFileSpec (const CP_FileSystemSpec &inFileSpec)
Testers
bool IsOpen ()

Protected Member Functions

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

Protected Attributes

CP_FileSystemSpec fFileSpec
OSFileRef fRefNum
OSFileRef fDataForkRefNum
OSFileRef fResourceForkRefNum

Detailed Description

This class is implemented for each of the supported platforms through a CP_File_Imp class.

The name and location of this file object is defined by its CP_FileSystemSpec.


Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_File::CP_File  ) 
 

Constructor.

You will need to call SetFileSpec on this object before you can work with this file object, as this default constructor does not represent a valid file system object.

Exceptions:
none 

CP_File::CP_File const CP_FileSystemSpec inFileSpec  ) 
 

Constructor. Constructs the file from the passed in CP_FileSystemSpec.

Parameters:
inFileSpec CP_FileSystemSpec object that specifies the name and location of the file. If the file has not yet been created, then this is the specification used to create the platforms file.
Exceptions:
none 

CP_File::~CP_File  )  [virtual]
 

Destructor.

Exceptions:
none 


Member Function Documentation

void CP_File_Imp::Create FourCharCode  inCreator,
FourCharCode  inType = kCP_Text_FileType
[inherited]
 

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::Create FourCharCode  inCreator,
FourCharCode  inType = kCP_Text_FileType
[inherited]
 

void CP_File_Imp::Create FourCharCode  inCreator,
FourCharCode  inType = kCP_Text_FileType
[inherited]
 

void CP_File_Imp::Open SInt16  inPermissions = CP_E_FilePerm_ReadWrite  )  [inherited]
 

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::Open SInt32  inPermissions = CP_E_FilePerm_ReadWrite,
bool  inOpenResourceFork = true
[inherited]
 

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

void CP_File_Imp::Open SInt32  inPermissions = CP_E_FilePerm_ReadWrite  )  [inherited]
 

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  )  [inherited]
 

Closes the file in the platforms file system.

Returns:
void

void CP_File_Imp::Close  )  [inherited]
 

void CP_File_Imp::Close  )  [inherited]
 

SInt64 CP_File_Imp::Length  )  [inherited]
 

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::Length  )  [inherited]
 

SInt64 CP_File_Imp::Length  )  [inherited]
 

SInt64 CP_File_Imp::GetPosition  )  const [inherited]
 

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::GetPosition  )  const [inherited]
 

SInt64 CP_File_Imp::GetPosition  )  const [inherited]
 

SInt64 CP_File_Imp::SetPosition UInt16  inMode,
SInt64  inOffset
[inherited]
 

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.

SInt64 CP_File_Imp::SetPosition UInt16  inMode,
SInt64  inOffset
[inherited]
 

SInt64 CP_File_Imp::SetPosition UInt16  inMode,
SInt64  inOffset
[inherited]
 

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

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::ReadData void *  inDataBuffer,
UInt32  inDataSize,
UInt16  inPositionMode = CP_E_FileSeek_FromCurrent,
SInt64  inOffset = 0
[inherited]
 

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

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

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.

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

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

bool CP_File_Imp::IsOpen  )  [inherited]
 

bool CP_File_Imp::IsOpen  )  [inherited]
 

bool CP_File_Imp::IsOpen  )  [inherited]
 

SInt16 CP_File_Imp::OpenFork SInt32  inPermissions,
const HFSUniStr255 &  inForkName
[inherited]
 

CP_FileSystemSpec CP_File_Imp::GetFileSpec  )  [inherited]
 

CP_FileSystemSpec CP_File_Imp::GetFileSpec  )  [inherited]
 

OSFileRef CP_File_Imp::GetRefNumber  )  [inherited]
 

void CP_File_Imp::SetEOF SInt32  inEOF  )  [inherited]
 

void CP_File_Imp::SetEOF SInt32  inEOF  )  [inherited]
 

void CP_File_Imp::UseResFile  )  [inherited]
 

void CP_File_Imp::SetFileSpec const CP_FileSystemSpec inFileSpec  )  [inherited]
 

void CP_File_Imp::SetFileSpec const CP_FileSystemSpec inFileSpec  )  [inherited]
 

void CP_File_Imp::FlushFork SInt16  inRefNum  )  [inherited]
 

const HFSUniStr255 & CP_File_Imp::GetDataForkName  )  [protected, inherited]
 

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, inherited]
 

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.


Member Data Documentation

CP_FileSystemSpec CP_File_Imp::fFileSpec [protected, inherited]
 

OSFileRef CP_File_Imp::fRefNum [protected, inherited]
 

CP_FileSystemSpec containing the name and location of this file.

OSFileRef CP_File_Imp::fDataForkRefNum [protected, inherited]
 

CP_FileSystemSpec containing the name and location of this file.

OSFileRef CP_File_Imp::fResourceForkRefNum [protected, inherited]
 

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