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

oofFileRef Class Reference
[OOFILE file and directory manipulation.]

#include <ooffiles.h>

List of all members.


Detailed Description

Portable way to refer to files.

Macintosh version allows specification via FSSpec structure and vol/dir ID plus filenames as well as the traditional file path string.

Todo:
replace FSSpec with FSRef for later Carbon builds and Mach-O on Macintosh.

add oofBlob readBinaryFile() const;

add void writeBinaryFile(oofBlob&) const;


file manipulation that can throw exceptions, oofE_MacOSErr or oofE_General

void gotoParentDirectory () const
oofString readTextFile () const
 Read contents of file in one hit as string.

void readBinary (oofSharedBLOB *) const
void writeTextFile (oofString &theStr) const
void deleteFile (bool ignoreMissingFiles=true) const
void renameFile (const oofString &newName)
void copyToDirectory (const oofDirectory &, bool overwriteDest=false) const
void moveToDirectory (const oofDirectory &, bool overwriteDest=false)

reflective methods

oofString path () const
oofString filename () const
oofDirectory directory () const
bool isDirectory () const
tm created () const
 Get file creation date/time.

tm lastModified () const
 Get file last modification date/time.

unsigned long fileSize (bool wantPhysical=true) const
bool dirIsParent (const oofDirectory &) const

Public Types

enum  isDirT { eDir, eFile, eNotSet }

Public Member Functions

 oofFileRef (const oofString &, isDirT isDir=eNotSet)
 oofFileRef (const char *path=0, isDirT isDir=eNotSet)
 default ctor allows you to create oofFileRef then assign

 oofFileRef (const oofDirectory &theDir, const oofString &name, isDirT isDir=eNotSet)
 oofFileRef (const FSSpec &, isDirT isDir=eNotSet)
 oofFileRef (short vRefNum, long dirID, const oofString &name, isDirT isDir=eNotSet)
 operator FSSpec & ()
const FSSpec & spec () const
const oofFileRefoperator= (const FSSpec &)
bool scanVolsUntilFound ()
const oofFileRefoperator= (const oofString &)
void clear ()
bool isValid () const
oofFileRef makeRefToContainedFile (const oofString &name) const
void extract (std::ostream &) const
FILE * fopen (const char *mode="rb") const
OSErr readCInfo (CInfoPBRec &cibr) const
void setFileType (OSType typeCode, OSType creatorCode=0)
void flushVolume () const


Member Enumeration Documentation

enum oofFileRef::isDirT
 

Enumeration values:
eDir 
eFile 
eNotSet 


Constructor & Destructor Documentation

oofFileRef::oofFileRef const oofString ,
isDirT  isDir = eNotSet
 

oofFileRef::oofFileRef const char *  path = 0,
isDirT  isDir = eNotSet
 

default ctor allows you to create oofFileRef then assign

oofFileRef::oofFileRef const oofDirectory theDir,
const oofString name,
isDirT  isDir = eNotSet
 

oofFileRef::oofFileRef const FSSpec &  ,
isDirT  isDir = eNotSet
 

oofFileRef::oofFileRef short  vRefNum,
long  dirID,
const oofString name,
isDirT  isDir = eNotSet
 


Member Function Documentation

void oofFileRef::clear  ) 
 

void oofFileRef::copyToDirectory const oofDirectory ,
bool  overwriteDest = false
const
 

tm oofFileRef::created  )  const
 

Get file creation date/time.

Todo:
move common time translation code in lastModified out to utility method.

void oofFileRef::deleteFile bool  ignoreMissingFiles = true  )  const
 

oofDirectory oofFileRef::directory  )  const [inline]
 

bool oofFileRef::dirIsParent const oofDirectory  )  const
 

void oofFileRef::extract std::ostream &   )  const
 

oofString oofFileRef::filename  )  const
 

unsigned long oofFileRef::fileSize bool  wantPhysical = true  )  const
 

void oofFileRef::flushVolume  )  const
 

FILE * oofFileRef::fopen const char *  mode = "rb"  )  const
 

void oofFileRef::gotoParentDirectory  )  const [inline]
 

bool oofFileRef::isDirectory  )  const
 

bool oofFileRef::isValid  )  const
 

tm oofFileRef::lastModified  )  const
 

Get file last modification date/time.

oofFileRef oofFileRef::makeRefToContainedFile const oofString name  )  const
 

void oofFileRef::moveToDirectory const oofDirectory ,
bool  overwriteDest = false
 

oofFileRef::operator FSSpec &  )  [inline]
 

const oofFileRef & oofFileRef::operator= const oofString  ) 
 

const oofFileRef & oofFileRef::operator= const FSSpec &   ) 
 

oofString oofFileRef::path  )  const
 

void oofFileRef::readBinary oofSharedBLOB  )  const
 

OSErr oofFileRef::readCInfo CInfoPBRec &  cibr  )  const
 

oofString oofFileRef::readTextFile  )  const
 

Read contents of file in one hit as string.

Appends a terminating null to the string that is read so it is a legal oofString. Use fopen if you want to read binary data.

Warning:
if you attempt to read binary data which contains a null you will trigger an assert in oofString because strlen() won't match the length read.

leaves file open if throw an exception.

Todo:
write tests and see for which errors can safely close before throwing exception.

return oofRefString when we add that class, to save copying buffers

implement Windows version

void oofFileRef::renameFile const oofString newName  ) 
 

bool oofFileRef::scanVolsUntilFound  ) 
 

void oofFileRef::setFileType OSType  typeCode,
OSType  creatorCode = 0
 

const FSSpec& oofFileRef::spec  )  const [inline]
 

void oofFileRef::writeTextFile oofString theStr  )  const
 

Warning:
leaves file open if throw an exception.
Todo:
write tests and see for which errors can safely close before throwing exception.


The documentation for this class was generated from the following files:
Generated on Fri Jan 2 00:57:23 2004 for OOFILE by doxygen 1.3.5