Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

CascadeFSObject Class Reference

base class for CascadeFile and CascadeDirectory, encompassing common functions. More...

#include <cascade/util/CascadeFSObject.h>

Inheritance diagram for CascadeFSObject:

CascadeObject CascadeDirectory CascadeFile List of all members.

Public Types

enum  FSCopyError {
  eFSCopyNoErr, eFSCopyCanceled, eFSCopyUnknownErr, eFSCopyDestExists,
  eFSCopyCantOpenSrc, eFSCopyCantCreateDest, eFSCopyCantOpenDest, eFSCopyReadSrcFailed,
  eFSCopyWriteDstFailed, eFSCopyDestIsSrc, eFSCopyDestInsideSrc, eFSCopyInsufficientSpace,
  eFSCopyBadParam, eFSCopyPermissionErr
}

Public Member Functions

 CascadeFSObject ()
 CascadeFSObject (const char *pName)
virtual ~CascadeFSObject ()
virtual CascadeString GetName (void) const
virtual bool SetName (const char *inName)
virtual CascadeString GetFullPath (void) const
virtual CascadeString GetFilenameExtension (void) const
virtual CascadeFSObjectGetParent (void) const
virtual bool IsDirectory (void) const =0
virtual bool Exists (void) const
virtual bool IsRoot (void) const

Static Public Member Functions

static bool Exists (const CascadeString &inPath)
static bool IsDirectory (const CascadeString &inPath)

Protected Attributes

void * m_pFSObjInternal
CascadeString m_fullPath

Classes

class  PermissionsSelector
 Selector object which uses file permissions to determine match More...
class  RegexpSelector
 Selector object which uses a regular expression test on the object name. More...
class  Selector
 abstract base class for selectors passed into CascadeDirectory enumration functions. CascadeFSObject::Selector is an abstract base class used to define objects which select the desired files when using the directory enumeration functions in CascadeDirectory. More...
class  TypeSelector
 Selector object which selects files, folders or both More...

Detailed Description

base class for CascadeFile and CascadeDirectory, encompassing common functions.

Skip the description

CascadeFSObject represents an object in the filesystem, whether it be a file or directory. It provides for the setting and getting of the object's name and/or full path, as well as some utility tests for whether the object exists, is a directory, or is the root directory. This allows, for example, an application to enumerate the contents of a directory into a list CascadeFSObjects, then use the IsDirectory() test to cast specific elements to a CascadeFile or CascadeDirectory object, using dynamic_cast.

This class includes a sub-class called Selector. This object is used with CascadeDirectory to filter the contents of a directory. Two basic selectors are provided as well: one which filters based upon the name, using regular expressions, and one which filters based upon permissions.


class CascadeFSObject


Member Enumeration Documentation

enum CascadeFSObject::FSCopyError
 

Enumeration values:
eFSCopyNoErr 
eFSCopyCanceled 
eFSCopyUnknownErr 
eFSCopyDestExists 
eFSCopyCantOpenSrc 
eFSCopyCantCreateDest 
eFSCopyCantOpenDest 
eFSCopyReadSrcFailed 
eFSCopyWriteDstFailed 
eFSCopyDestIsSrc 
eFSCopyDestInsideSrc 
eFSCopyInsufficientSpace 
eFSCopyBadParam 
eFSCopyPermissionErr 


Constructor & Destructor Documentation

CascadeFSObject::CascadeFSObject  ) 
 

default constructor

Create a CascadeFSObject that doesn't yet point to anything in the filesystem. (Note that this class is pure virtual, so the construcor does common default initialization for base classes. When constructing one of those sub-class objects without a name, you will need to call SetName to bind it to a real filesystem object.

CascadeFSObject::CascadeFSObject const char *  pName  ) 
 

parameterized constructor

Create a CascadeFSObject pointing to an object in the hierarchy. The object need not already exist -- the sub-class objects have functions to create the objects. (Note that this class is pure virtual, so this constructor performs common default initialization for the derived classes.)

Parameters:
pName the name or full path for the object

virtual CascadeFSObject::~CascadeFSObject  )  [virtual]
 

destructor

Destructor.


Member Function Documentation

static bool CascadeFSObject::Exists const CascadeString inPath  )  [static]
 

test for existence of path

Static utility function returns true if there is something at the path specified.

Parameters:
inPath a path
Returns:
true if the path exists, false otherwise

virtual bool CascadeFSObject::Exists void   )  const [virtual]
 

test for existence of this object

Returns true if the object exists, or false otherwise. CascadeFile and CascadeDirectory objects have facilities to create filesystem objects that don't already exist.

Returns:
true if object exists, else false

virtual CascadeString CascadeFSObject::GetFilenameExtension void   )  const [virtual]
 

get the object's filename extension

Returns the filename extension of this object, not including the '.' character. i.e. a CascadeFile object pointing to /usr/local/bin/foo.bar will return "bar". In the case that a name contains more than one '.', the portion following the last one is treated as the extension. An initial '.' is ignored. Note that no length constraint is enforced, so "a.reallylongextension" will yield "reallylongextension". Returns an empty string (which must still be deleted) if there is no extension, or if the filename ends in the '.' character. The function will work on directories as well, so if you wish to exclude directories be sure to call IsDirectory() first.

Returns:
a CascadeString.

virtual CascadeString CascadeFSObject::GetFullPath void   )  const [virtual]
 

get the object's full path

Returns the complete path of this object, including the object's name itself. i.e. a CascadeFile object pointing to /usr/local/bin/vi will return "/usr/local/bin/vi". A CascadeDirectory pointing to /usr/local/bin will return "/usr/local/bin"

Returns:
a CascadeString.

virtual CascadeString CascadeFSObject::GetName void   )  const [virtual]
 

gets the object's name

Returns the name of this object. For example, a CascadeFile object pointing to "/usr/local/bin/vi" would return "vi", and a CascadeDirectory object pointing to "/usr/local/bin" would return "bin" (no trailing slash). Analogous to the basename library call.

Returns:
a CascadeString.

virtual CascadeFSObject* CascadeFSObject::GetParent void   )  const [virtual]
 

returns a new CascadeFSObject representing this one's parent

Returns the container of this object. You should be able to dynamic_cast the result to a CascadeDirectory if you want to use directory features.

Returns:
a new CascadeFSObject. Client must dispose with delete.

static bool CascadeFSObject::IsDirectory const CascadeString inPath  )  [static]
 

test whether path points to directory

Static utility function returns true if the path is valid and points to a directory

Parameters:
inPath the path to test
Returns:
true if inPath points to a directory; false otherwise

virtual bool CascadeFSObject::IsDirectory void   )  const [pure virtual]
 

test whether this object is a directory

Returns true if this object is a directory, false otherwise. Note that this is a pure virtual function; all subclasses must override and implement this function.

Returns:
true if this object is a directory, else false

Implemented in CascadeDirectory, and CascadeFile.

virtual bool CascadeFSObject::IsRoot void   )  const [virtual]
 

test for root

Returns true if the object is the root directory. Returns false if the directory object hasn't had its name set yet, or if it's not the root.

Returns:
true if this object represents the root directory ("/")

virtual bool CascadeFSObject::SetName const char *  inName  )  [virtual]
 

sets the object's name or full path

Set the name of this CascadeFSObject. The corresponding object in the filesystem need not exist. Note that a leading slash will cause the submitted string to be treated as a full path. Otherwise, it will be treated as a name or path relative to the current working directory. Returns false in the case of a failure (unlikely, except for out-of-memory).

Parameters:
inName a standard C string containing the desired name
Returns:
whether or not setting was successful (a copy is made of the name, which could fail)

Reimplemented in CascadeFile.


Member Data Documentation

CascadeString CascadeFSObject::m_fullPath [protected]
 

void* CascadeFSObject::m_pFSObjInternal [protected]
 


The documentation for this class was generated from the following file:
Generated on Sun Jul 24 14:27:19 2005 for Cascade Library by  doxygen 1.4.1