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

CP_FileSystemSpec Class Reference

Class to manage the specification of a file in the platforms file system. More...

Inheritance diagram for CP_FileSystemSpec:

CP_FileSystemSpec_Imp List of all members.

Public Member Functions

void GetParent (FSRef &inOutParentRef) const
FSRefResult GetParent () const
void GetName (HFSUniStr255 &inOutName) const
CP_String GetName () const
FSRefResult GetFSRef () const
FSSpec GetFSSpec () const
OSVolume GetVolume () const
SInt16 GetVolumeID () const
SInt32 GetParID () const
CP_CFURL GetAsCFURL ()
CP_String GetFullPath_Posix () const
CP_String GetFullPath_HFS () const
bool operator== (const CP_FileSystemSpec_Imp &inFileSpec)
bool operator!= (const CP_FileSystemSpec_Imp &inFileSpec)
void Set (FSRef inFileRef)
void Set (const CP_String &inName, FSRef inParentRef)
void Set (const FSSpec &inFSSpec, CFStringEncoding inEncoding=::CFStringGetSystemEncoding())
void Set (SInt16 vRefNum, SInt32 dirID)
void Set (const CP_String &inFullpath)
void SetName (const CP_String &inFileName)
bool IsValid () const
bool ExistsOnDisk () const
bool IsDirectory () const
bool IsEqual (const CP_FileSystemSpec_Imp &) const
void AssertDecomposedForm () const
 Makes sure the filespec is in decomposed form (parentDirRef + name).
Constructor / Destructor
 CP_FileSystemSpec ()
 Constructor.
 CP_FileSystemSpec (const CP_FileSystemSpec &inFileSpec)
 CP_FileSystemSpec (const CP_String &inFullPath)
 CP_FileSystemSpec (const CP_FileSystemSpec &inParent, const CP_String &inName)
 CP_FileSystemSpec (FSRef inFileRef)
 CP_FileSystemSpec (const FSSpec &inFSSpec, CFStringEncoding inEncoding=::CFStringGetSystemEncoding())
virtual ~CP_FileSystemSpec ()
 Destructor.
Getters
CP_FileSystemSpec GetParentSpec () const
CP_String GetFullPath () const
operators
const CP_FileSystemSpecoperator= (const CP_FileSystemSpec &inFileSpec)
bool operator== (const CP_FileSystemSpec &inFileSpec) const
bool operator!= (const CP_FileSystemSpec &inFileSpec) const

Protected Member Functions

FSRef FSSpecToFSRef (const FSSpec &inFSSpec)
FSSpec FSRefToFSSpec (const FSRef &inFSRef)
CP_String GetFullPathInStyle (CFURLPathStyle inPathStyle) const

Protected Attributes

bool fExists
bool fIsValid
FSRef fRef
CP_String fName

Detailed Description

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


Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_FileSystemSpec::CP_FileSystemSpec  ) 
 

Constructor.

Exceptions:
none 

CP_FileSystemSpec::CP_FileSystemSpec const CP_FileSystemSpec inFileSpec  ) 
 

Copy constructor.

Parameters:
inFileSpec CP_FileSystemSpec to copy the fields from.
Exceptions:
none 

CP_FileSystemSpec::CP_FileSystemSpec const CP_String inFullPath  ) 
 

Constructor. This version specifies the file from the passed in full path.

Parameters:
inFullPath CP_String containing the full path to the file.
Exceptions:
none 

CP_FileSystemSpec::CP_FileSystemSpec const CP_FileSystemSpec inParent,
const CP_String inName
 

Constructor. This version specifies the file from a parent file spec that points to the parent folder, and a string that contains the file name.

Parameters:
inParent CP_FileSystemSpec that points to the parent directory for this file.
inName The name of the file.
Exceptions:
none 

CP_FileSystemSpec::CP_FileSystemSpec FSRef  inFileRef  ) 
 

Constructor. This constructs the file system spec from a MacOS FSRef.

Parameters:
inFileRef MacOS FSRef to construct file from.
Exceptions:
none 

CP_FileSystemSpec::CP_FileSystemSpec const FSSpec &  inFSSpec,
CFStringEncoding  inEncoding = ::CFStringGetSystemEncoding()
 

Constructor. This constructs the file system spec from a MacOS FSSpec.

Parameters:
inFSSpec MacOS FSSpec to construct file from.
inEncoding String encoding to encode the name.
Exceptions:
none 

CP_FileSystemSpec::~CP_FileSystemSpec  )  [virtual]
 

Destructor.

Exceptions:
none 


Member Function Documentation

CP_FileSystemSpec CP_FileSystemSpec::GetParentSpec  )  const
 

Returns a CP_FileSystemSpec that points to the parent directory for this object.

Exceptions:
none 
Returns:
CP_FileSystemSpec Returns a CP_FileSystemSpec that points to the parent of this object.

CP_String CP_FileSystemSpec::GetFullPath  )  const
 

Returns the full path of this file system spec as a CP_String. Under MacOSX the path will be returned as a posix style path.

Exceptions:
none 
Returns:
const CP_String Returns a string containing the full path.

const CP_FileSystemSpec & CP_FileSystemSpec::operator= const CP_FileSystemSpec inFileSpec  ) 
 

Assignment operator.

Parameters:
inFileSpec CP_FileSystemSpec to copy the fields from.
Exceptions:
none 
Returns:
const CP_FileSystemSpec& Returns a reference to ourselves.

bool CP_FileSystemSpec::operator== const CP_FileSystemSpec inFileSpec  )  const
 

Compares the passed in file spec for equality with this one.

Parameters:
inFileSpec CP_FileSystemSpec to compare against.
Exceptions:
none 
Returns:
bool const Returns true if the passed in file spec points to the same object as this one.

bool CP_FileSystemSpec::operator!= const CP_FileSystemSpec inFileSpec  )  const
 

void CP_FileSystemSpec_Imp::GetParent FSRef &  inOutParentRef  )  const [inherited]
 

Returns an FSRef to the parent folder of this file system specification.

Parameters:
inOutParentRef FSRef to hold the result.
Returns:
void

CP_FileSystemSpec_Imp::FSRefResult CP_FileSystemSpec_Imp::GetParent  )  const [inherited]
 

Returns an FSRef to the parent folder of this file system specification.
The FSRef is returned as an FSRefResult, which is a convenience class that can act as both an FSRef and a const FSRef *

Returns:
FSRefResult FSRef to the parent folder.

void CP_FileSystemSpec_Imp::GetName HFSUniStr255 &  inOutName  )  const [inherited]
 

Returns the name of the file as a HFSUniStr255 in the passed in parameter.

Parameters:
inOutName HFSUniStr255 to hold the result.
Returns:
void const

CP_String CP_FileSystemSpec_Imp::GetName  )  const [inherited]
 

Return the name of this file system object as a CP_Stringn.

Returns:
CP_String const Returns the name of the file that this spec points to.

CP_FileSystemSpec_Imp::FSRefResult CP_FileSystemSpec_Imp::GetFSRef  )  const [inherited]
 

Returns a reference to the FSRef for this file or folder. If the object does not exist on disk, or this object is not valid, an OSException is thrown with the errFSBadFSRef code.
The FSRef is returned as an FSRefResult, which is a convenience class that can act as both an FSRef and a const FSRef *

Returns:
FSRefResult Returns an FSRef for the file pointed to by this filesystem spec.

FSSpec CP_FileSystemSpec_Imp::GetFSSpec  )  const [inherited]
 

Returns a MacOS FSSpec for this file.

Returns:
FSSpec Returns a MacOS FSSpec.

OSVolume CP_FileSystemSpec_Imp::GetVolume  )  const [inherited]
 

SInt16 CP_FileSystemSpec_Imp::GetVolumeID  )  const [inherited]
 

Returns the volume id for this file system spec.

none

Returns:
SInt16 const The volume reference number.

SInt32 CP_FileSystemSpec_Imp::GetParID  )  const [inherited]
 

Returns the par id for this file system spec.

none

Returns:
SInt32 const The par id of this file.

CP_CFURL CP_FileSystemSpec_Imp::GetAsCFURL  )  [inherited]
 

CP_String CP_FileSystemSpec_Imp::GetFullPath_Posix  )  const [inherited]
 

CP_String CP_FileSystemSpec_Imp::GetFullPath_HFS  )  const [inherited]
 

bool CP_FileSystemSpec_Imp::operator== const CP_FileSystemSpec_Imp inFileSpec_Imp  )  [inherited]
 

Inequality operator. Checks if this object is not equal to the passed in CP_FileSystemSpec_Imp object.

Parameters:
inFileSpec_Imp Object to compare against.
Returns:
bool Returns true if the passed in file spec is not equal to this object.

bool CP_FileSystemSpec_Imp::operator!= const CP_FileSystemSpec_Imp inFileSpec  )  [inherited]
 

void CP_FileSystemSpec_Imp::Set FSRef  inFileRef  )  [inherited]
 

Sets this file system spec to point to the FSRef passed in.

Parameters:
inFileRef FSRef to an existing file system object.
Returns:
void

void CP_FileSystemSpec_Imp::Set const CP_String inFileName,
FSRef  inParentRef
[inherited]
 

Sets this file system spec to point to an object location in the parent folder specified by inParentRef with the file name inFileName. This could point to a non-existant file if it has not been created yet.

Parameters:
inFileName CP_String containing the name of the file or folder.
inParentRef FSRef to the parent folder of this object.
Returns:
void

void CP_FileSystemSpec_Imp::Set const FSSpec &  inFSSpec,
CFStringEncoding  inEncoding = ::CFStringGetSystemEncoding()
[inherited]
 

Sets this file system spec to point to the object specified in the passed inFSSpec. This could point to a non-existant file if it has not been created yet.

Parameters:
inFSSpec FSSpec for the file or folder.
inEncoding String encoding to use for the name.
Returns:
void

void CP_FileSystemSpec_Imp::Set SInt16  vRefNum,
SInt32  dirID
[inherited]
 

Sets this file system spec to point to the object specified in the passed volume reference number, and directory id. This specifies a folder.

Parameters:
vRefNum Volume reference number.
dirID Directory id.
Returns:
void

void CP_FileSystemSpec_Imp::Set const CP_String inFullPath  )  [inherited]
 

Sets this file system spec to point to the full path passed in.

Parameters:
inFileRef CP_String represented by the passed in string.
Returns:
void

void CP_FileSystemSpec_Imp::SetName const CP_String inFileName  )  [inherited]
 

bool CP_FileSystemSpec_Imp::IsValid  )  const [inherited]
 

Return true if this points to a valid file specification in the platforms native file system. The file can be valid, but not yet exist in the native file system.

Returns:
bool const True if the file specification is valid.

bool CP_FileSystemSpec_Imp::ExistsOnDisk  )  const [inherited]
 

Return true if this points to a file that currently exists in the platforms native file system.

Returns:
bool const True if the file exists in the platforms native file system.

bool CP_FileSystemSpec_Imp::IsDirectory  )  const [inherited]
 

Returns true if this file spec represents a directory.

Exceptions:
OSStatus OSStatus exception. CP_paramErr if this spec does not represent an existing file.
Returns:
bool const True if this file spec represents a directory.

bool CP_FileSystemSpec_Imp::IsEqual const CP_FileSystemSpec_Imp  )  const [inherited]
 

void CP_FileSystemSpec_Imp::AssertDecomposedForm  )  const [inherited]
 

Since an FSRef can't point to a non-existing file, file specs for those files must be represented as an FSRef for the parent directory and a string for the node's name.
This functions ensures that the CP_FileSystemSpec in question is represented in that form. This is important to make sure the filespec remains valid after removing a file.

Note:
This function is const, even though it modifies the contents, but since it doesn't change the semantical contents of the object, it's conceptually constant.
Exceptions:
Any OSErr exception may be raised if the filespec is not valid or if the file doesn't exist any more.

FSRef CP_FileSystemSpec_Imp::FSSpecToFSRef const FSSpec &  inFSSpec  )  [protected, inherited]
 

Returns a FSRef to the file specified in the passed in FSSpec. This throws an OSError exception if not successful.

Parameters:
inFSSpec FSSpec of the object to return FSRef for.
Returns:
FSRef FSRef to the object.

FSSpec CP_FileSystemSpec_Imp::FSRefToFSSpec const FSRef &  inFSRef  )  [protected, inherited]
 

Returns a FSSpec to the file specified in the passed in FSRef. This throws an OSError exception if not successful.

Parameters:
inFSRef FSRef of the object to return FSRef for.
Returns:
FSSpec FSSpec to the object.

CP_String CP_FileSystemSpec_Imp::GetFullPathInStyle CFURLPathStyle  inPathStyle  )  const [protected, inherited]
 


Member Data Documentation

bool CP_FileSystemSpec_Imp::fExists [protected, inherited]
 

bool CP_FileSystemSpec_Imp::fIsValid [protected, inherited]
 

flag to indicate if the file exists in the platforms file system

FSRef CP_FileSystemSpec_Imp::fRef [protected, inherited]
 

flag to indicate if this object holds a valid specification for a file, which may or may not currently exist in the file system.

CP_String CP_FileSystemSpec_Imp::fName [protected, inherited]
 

MacOS FSRef to the file


The documentation for this class was generated from the following files:
Generated on Tue Sep 20 20:21:46 2005 for CPLAT_MacOS by  doxygen 1.4.0