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

oofDirectory Class Reference
[OOFILE file and directory manipulation.]

#include <ooffiles.h>

Collaboration diagram for oofDirectory:

Collaboration graph
[legend]
List of all members.

Detailed Description

Provides cross-platform directory specification and iteration.

See also:
oofDirectoryVisitor for iterator object, eg; used to list directories or read a tree into a database (ooftst46).


reflective functions

bool validDir () const
bool containsFile (const char *justFileName) const
const oofStringpath () const
oofString filename () const
bool isEmpty () const
bool createdDiskDir () const

file lists and visiting

oofFileListmakeFileList () const
virtual void visitFiles (oofDirectoryVisitor &, unsigned long remainingVisitDepth=1024, bool firstVisit=true)
 Iterate through the directory tree applying Visitor.

void extract (std::ostream &)

Public Member Functions

 oofDirectory ()
 oofDirectory (short vRefNum, long dirID, bool searchForDirAllVols=false)
 oofDirectory (short vRefNum, long dirID, const char *fallBackPath, bool searchForDirAllVols=false)
 oofDirectory (const FSSpec &)
 oofDirectory (const char *path, char *outFileName=0, bool createSubdirsIfMissing=false, bool makeAbsolute=true)
virtual ~oofDirectory ()
void setDirFromPath (const char *path, char *outFileName=0, bool createSubdirsIfMissing=false, bool makeAbsolute=true)
 setDirFromPath core conversion routine for external call or constructing oofDirectory from incoming path

void gotoDirectory () const
 Change current dir to this oofDirectory.

bool openFile (const char *justFileName) const
 launch files as if double-click on desktop

void delDirectory (bool delDirAsWellAsContents=true, bool delTree=true, bool delSubdirs=true)
void fillInFSSpec (const char *nameCanBeNull, FSSpec &) const
 Fill in an FSSpec from our current member variables.

void closeWDDirectory ()

Static Public Member Functions

oofDirectory createDirectory (const char *path)
bool fileExists (const char *fullPath)
 Confirm a file exists.

void gotoDirectory (const oofString &)
 Make the directory identified by inPath the current default.

oofString FSSpecToPath (const FSSpec &)
void gotoDirectory (short vRefNum, long dirID)
 Make the directory identified by vRefNum & dirID the current default.

const char * parentDirPath ()
const char * relativeRootPath ()
char directoryTerminator ()

Protected Member Functions

void GetCurrentLocation ()
 Set this oofDirectory to point to current default location.

void PathToDirID (const unsigned char *pascalPath)
 Sets the oofDirectory to point to the directory identified by the path alters the members: mDirID possibly the mVRefNum if path is absolute Uses working directories, updating mWorkingDirID.

void createDirID (const unsigned char *pascalPartialPath=0, bool searchForDirAllVols=false)
 A simple wrapper to call the approriate directory method depending on target enviroment.

void CreateHardDirID (const unsigned char *pascalPartialPath, bool searchForDirAllVols)
void CreateWorkingDirID (const unsigned char *pascalPartialPath=0, bool searchForDirAllVols=false)
 Search for the directory from current location for the directory identified by the partial path and set: mWorkingDirID mValidDir mVRefNum if the dir is found.

void CreateSubDirs (const unsigned char *pascalPartialPath)
 a simple wrapper to allow us to call CreateSubdirsAndWorkingDirID Will modify members: mWorkingDirID mVRefNum

void CreateSubdirsAndWorkingDirID (const unsigned char *pascalPartialPath)
 Find the directory identified by pascalPartialPath and make the oofDirectory point to the directory.


Protected Attributes

short mVRefNum
 volume number of a mounted volume, not meaningful over reboots

short mWorkingDirID
 old Mac Classic Working Directory number, combines mVRefNum & mDirID

long mDirID
 directory ID on specified volume, preserved unless dir recreated.

oofString mPath
bool mValidDir
bool mCreatedDiskDir


Constructor & Destructor Documentation

oofDirectory::oofDirectory  ) 
 

oofDirectory::oofDirectory short  vRefNum,
long  dirID,
bool  searchForDirAllVols = false
 

oofDirectory::oofDirectory short  vRefNum,
long  dirID,
const char *  fallBackPath,
bool  searchForDirAllVols = false
 

oofDirectory::oofDirectory const FSSpec &   ) 
 

oofDirectory::oofDirectory const char *  path,
char *  outFileName = 0,
bool  createSubdirsIfMissing = false,
bool  makeAbsolute = true
 

oofDirectory::~oofDirectory  )  [virtual]
 


Member Function Documentation

void oofDirectory::closeWDDirectory  ) 
 

bool oofDirectory::containsFile const char *  justFileName  )  const
 

bool oofDirectory::createdDiskDir  )  const [inline]
 

oofDirectory oofDirectory::createDirectory const char *  path  )  [static]
 

void oofDirectory::createDirID const unsigned char *  pascalPartialPath = 0,
bool  searchForDirAllVols = false
[protected]
 

A simple wrapper to call the approriate directory method depending on target enviroment.

void oofDirectory::CreateHardDirID const unsigned char *  pascalPartialPath,
bool  searchForDirAllVols
[protected]
 

void oofDirectory::CreateSubDirs const unsigned char *  pascalPartialPath  )  [protected]
 

a simple wrapper to allow us to call CreateSubdirsAndWorkingDirID Will modify members: mWorkingDirID mVRefNum

Will set mValidDir = true if sucseeful else false mWorkingDirID, &mVRefNum, &mDirID

void oofDirectory::CreateSubdirsAndWorkingDirID const unsigned char *  pascalPartialPath  )  [protected]
 

Find the directory identified by pascalPartialPath and make the oofDirectory point to the directory.

If the directory does not exist create it and any other missing directories. Will modify members: mWorkingDirID mVRefNum

Will set mValidDir = true if sucseeful else false mWorkingDirID, &mVRefNum, &mDirID

Algorithm is as follows. IF we have a partial path IF path is relative THEN GET default working directory ID ELSE IF path is absolute AND vol name in path exists THEN SET mVRefNum = volnum of vol with name at beginning of pascalPartialPath ELSE SET mValidDir = false END_IF

END_IF IF volume exists THEN GET catinfo on named object IF named object exists THEN GET catinfo on named object IF named object is dir create a working directory and SET mWorkingDirID ELSE SET mValidDir false it's a file or something return END_IF ELSE // must make a directory loop back through path name until an existing folder name is found or in current dir loop through path name from valid point creating missing nested directories PBOpenWD SET mWorkingDirID to wpb.ioVRefNum (jus open wdirectory) ELSE SET mValidDir = false END_IF IF mValidDir THEN convert current dir to path END_IF ELSE CALL GETCurrentLocation ENDIF

void oofDirectory::CreateWorkingDirID const unsigned char *  pascalPartialPath = 0,
bool  searchForDirAllVols = false
[protected]
 

Search for the directory from current location for the directory identified by the partial path and set: mWorkingDirID mValidDir mVRefNum if the dir is found.

Todo:
check if PBOpenWDSync can handle paths like :::sea:saw:

void oofDirectory::delDirectory bool  delDirAsWellAsContents = true,
bool  delTree = true,
bool  delSubdirs = true
 

char oofDirectory::directoryTerminator  )  [inline, static]
 

void oofDirectory::extract std::ostream &   ) 
 

bool oofDirectory::fileExists const char *  fullPath  )  [static]
 

Confirm a file exists.

Warning:
very old code relying on parsing Pascal paths
Todo:
rewrite to use relative path conversion

handle larger paths, maybe using oofFileRef

oofString oofDirectory::filename  )  const
 

void oofDirectory::fillInFSSpec const char *  filename,
FSSpec &  ioSpec
const
 

Fill in an FSSpec from our current member variables.

Todo:
investigate use of mac api call FSMakeFSSpec

OOF_String oofDirectory::FSSpecToPath const FSSpec &   )  [static]
 

void oofDirectory::GetCurrentLocation  )  [protected]
 

Set this oofDirectory to point to current default location.

By getting Current default volume and directory, then setting members: mVRefNum mDirID mWorkingDirID mPath

void oofDirectory::gotoDirectory const oofString inPath  )  [static]
 

Make the directory identified by inPath the current default.

void oofDirectory::gotoDirectory  )  const
 

Change current dir to this oofDirectory.

directory identified by mWorkingDirID (classic) or mVRefNum & mDirID (classic or carbon)

bool oofDirectory::isEmpty  )  const
 

oofFileList * oofDirectory::makeFileList  )  const
 

bool oofDirectory::openFile const char *  justFileName  )  const
 

launch files as if double-click on desktop

const char * oofDirectory::parentDirPath  )  [inline, static]
 

const oofString & oofDirectory::path  )  const [inline]
 

void oofDirectory::PathToDirID const unsigned char *  pascalPath  )  [protected]
 

Sets the oofDirectory to point to the directory identified by the path alters the members: mDirID possibly the mVRefNum if path is absolute Uses working directories, updating mWorkingDirID.

const char * oofDirectory::relativeRootPath  )  [inline, static]
 

void oofDirectory::setDirFromPath const char *  path,
char *  outFileName = 0,
bool  createSubdirsIfMissing = false,
bool  makeAbsolute = true
 

setDirFromPath core conversion routine for external call or constructing oofDirectory from incoming path

a non-null outFileName indicates the caller expects the path to terminate in a filename

incoming paths converted if possible

bool oofDirectory::validDir  )  const [inline]
 

void oofDirectory::visitFiles oofDirectoryVisitor theVisitor,
unsigned long  remainingVisitDepth = 1024,
bool  firstVisit = true
[virtual]
 

Iterate through the directory tree applying Visitor.

Todo:
fix Windows version for CodeWarrior - missing makepath.


Member Data Documentation

bool oofDirectory::mCreatedDiskDir [protected]
 

long oofDirectory::mDirID [protected]
 

directory ID on specified volume, preserved unless dir recreated.

oofString oofDirectory::mPath [protected]
 

bool oofDirectory::mValidDir [protected]
 

short oofDirectory::mVRefNum [protected]
 

volume number of a mounted volume, not meaningful over reboots

short oofDirectory::mWorkingDirID [protected]
 

old Mac Classic Working Directory number, combines mVRefNum & mDirID


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