#include <cascade/util/CascadeDirectory.h>
Inheritance diagram for CascadeDirectory:
Public Types | |
typedef bool() | DirectoryEnumerationCallback (CascadeFSObject *obj, void *pClientData) |
typedef bool() | DirCopyCallback (u32 inTotal, u32 inComplete, const CascadeString &inCurrentName, void *pClientData) |
Public Member Functions | |
CascadeDirectory () | |
CascadeDirectory (const char *pName) | |
virtual | ~CascadeDirectory () |
virtual bool | Create (mode_t inMode=0666) |
virtual bool | Delete (bool inRecursive) |
virtual bool | GetChildCount (u32 &outCount, bool inRecursive, bool inSkipInvisible) const |
virtual bool | GetChildren (CascadeTemplateArray< CascadeFSObject * > *&outChildren, bool inRecursive, bool inSkipInvisible) const |
virtual bool | GetMatchingChildCount (CascadeFSObject::Selector &inSelector, bool inRecursive, bool inSkipInvisible, u32 &outCount) const |
virtual bool | GetMatchingChildren (CascadeFSObject::Selector &inSelector, bool inRecursive, bool inSkipInvisible, CascadeTemplateArray< CascadeFSObject * > *&outChildren) const |
virtual bool | EnumerateMatchingChildren (CascadeFSObject::Selector &inSelector, bool inRecursive, bool inSkipInvisible, DirectoryEnumerationCallback inCallback, void *inClientData) const |
virtual bool | SetCWD (void) const |
virtual bool | CopyTo (CascadeDirectory &inDestination, bool inRecursive, DirCopyCallback *inCallback, void *inClientData, CascadeFile::FileCopyCallback *inFileCallback, void *inFileClientData, FSCopyError &outError) |
virtual bool | Contains (const CascadeFSObject *inObject, bool &outContains) |
virtual bool | IsDirectory (void) const |
Static Public Member Functions | |
static CascadeDirectory * | GetCWD (void) |
CascadeDirectory is a sub-class of CascadeFSObject, and provides easy to use object-based access to directory operations, most notably getting and setting the current working directory (CWD) and counting and enumerating the contents of a given directory. Directory creation and deletion are also supported.
|
callback function for CopyTo method Create a callback function of this signature to pass to the CopyTo method. Information is provided to calculate the progress of the copy operation, and display the current file or directory name that is being copied. Return true from your callback to allow the copy to proceed. Return false to cause the copy to stop. (The copy will return a false return value if canceled in this way.)
|
|
callback function for EnumerateMatchingChildren method Create a callback function of this signature to pass to the EnumerateMatchingChildren method. Each matching child is passed to this function, along with the client data pointer supplied as an argument to EnumerateMatchingChildren. THE OBJECT POINTER MAY BE NULL. In order to ensure that clients have timely access to aborting the enumeration, the callback will be called with a NULL object pointer if 100 consecutive objects found do not match the selector. Be sure you test for NULL! The callback should return true if enumeration is to continue. To stop the enumeration, return false.
|
|
default constructor Creates a CascadeDirectory object for later use. You must call SetName before this object will be usable for anything. |
|
parameterized constructor Creates a CascadeDirectory object with the supplied name. Note that the corresponding directory need not exist in the filesystem. You can create one by calling Create().
|
|
destructor Destructor |
|
is the supplied object contained in this directory? If the supplied object is contained within this directory, including within a sub-directory of this directory, outContains is set to true. Otherwise, outContains is set to false. The function itself returns false if there is an error, and outContains is not touched.
|
|
copy the contents of this directory into destination Copies the contents of this directory into the destination directory. The destination must exist. If inRecursive is true, then sub-directories are duplicated in the destination as well. If inCallback is provided, it is called to allow progress display. You may also supply a file callback of the same type taken by CascadeFile::CopyInto. This will allow you to provide more-detailed progress feedback and to interrupt the copying of large files before completion of the current file.
|
|
creates a directory Creates a directory in the filesystem matching this object's path and name, using the supplied mode.
|
|
deletes the directory from the filesystem Deletes this directory from the filesystem. If inRecursive is true, the directory and its contents will be deleted. Otherwise, the directory must be empty for this function to succeed. May fail (and return false) if permissions are inadequate, if the specified directory doesn't exist, or if the name of this object has not been set.
|
|
Scans a directory, calling a callback for each match For each child in this directory which matches a set of criteria, the supplied callback function is called, and a new CascadeFSObject is returned. The callback should return false to abort the enumeration. The client is responsible for deleting the returned object. Also, in order to ensure that clients can abort the scan in a timely fashion, the callback is called for non-matching items, but in this case, the CascadeFSObject pointer will be NULL. Be sure to check this before using! The inClientData pointer is supplied to the callback function each time it is called, whether or not the item pointer is NULL. Includes sub-directory contents if inRecursive is true. ".", ".." and any hard links to them are excluded. Symlinked files are considered. Symlinked directories are not traversed if inRecursive is true. If inSkipInvisible is true, files with names beginning with '.' are skipped, and directories with names beginning with '.' are not traversed. Any directory named "resource.frk" is also skipped if inSkipInvisible is true. The criteria are embodied in a selector, supplied to the this function. Some common selectors are supplied with the CascadeFSObject class, or the user may define their own. Returns true if results are valid. Returns true if the enumeration was canceled early by teh callback. Returns false in the event of error. Errors may include insufficient memory to enumerate all children, calling this function on a non-existent directory, or calling this function without setting the name of the CascadeDirectory object.
|
|
count children of this directory Gets the number of contained objects in the directory. Includes sub-directory contents as well, if inRecursive is true. (Note that in the recursive case, a sub-directory with two items in it counts as three children.) outCount may be zero. ".", ".." and any hard links to them are excluded. Linked directories are also skipped if inRecursive is true (to prevent cycles). Items whose names begin |
|
returns all children of the directory
Returns an array of CascadeFSObject pointers representing the contained children of this directory. Includes sub-directory contents if inRecursive is true. Allocates the returned objects and the array itself. The caller is responsible for disposing the array and its contents (you must
|
|
static function returns current working directory Static function to create a CascadeDirectory object representing the current working directory.
|
|
returns a count of child objects matching selector criteria Returns the number of contained files matching a set of criteria. If inRecursive is true, this count will include the contents of any contained directories. Otherwise, only direct children of this directory are returned. ".", ".." and any hard links to them are excluded. Symlinked files are considered. Symlinked directories are not traversed if inRecursive is true. If inSkipInvisible is true, files with names beginning with '.' are skipped, and directories with names beginning with '.' are not traversed. Any directory named "resource.frk" is also skipped if inSkipInvisible is true. The criteria are embodied in a selector, supplied to the this function. Some common selectors are supplied with the CascadeFSObject class, or the user may define their own.
|
|
returns an array of matching children Returns an array of CascadeFSObject pointers representing children of this directory which match a set of criteria. Includes sub- directory contents if inRecursive is true. Allocates the returned objects and the array. The caller is responsible for disposal of these objects and the array itself. ".", ".." and any hard links to them are excluded. Symlinked files are considered. Symlinked directories are not traversed if inRecursive is true. If inSkipInvisible is true, files with names beginning with '.' are skipped, and directories with names beginning with '.' are not traversed. Any directory named "resource.frk" is also skipped if inSkipInvisible is true. The criteria are embodied in a selector, supplied to the this function. Some common selectors are supplied with the CascadeFSObject class, or the user may define their own. Returns true if results are valid. Returns false and leaves outChildren untouched in the event of error. Errors may include insufficient memory to enumerate all children, calling this function on a non-existent directory, or calling this function without setting the name of the CascadeDirectory object.
|
|
returns true, always Mandatory override of the pure virtual superclass function.
Implements CascadeFSObject. |
|
set this directory to be current working directory Sets this directory to be the current working directory. Return value indicates success. May fail if the directory does not exist, or if the name has not been set. See also the StSetCWD utility class.
|