G::Directory Class Reference

An encapsulation of a file system directory which allows for iterating through the set of contained files. More...

#include <gdirectory.h>

List of all members.

Public Member Functions

 Directory ()
 Default constructor for the current directory.
 Directory (const char *path)
 Constructor.
 Directory (const Path &path)
 Constructor.
 Directory (const std::string &path)
 Constructor.
 ~Directory ()
 Destructor.
bool valid (bool for_creating_files=false) const
 Returns true if the object represents a valid directory.
bool writeable (std::string probe_filename=tmp()) const
 Tries to create and then delete an empty test file in the directory.
Path path () const
 Returns the directory's path.
 Directory (const Directory &other)
 Copy constructor.
Directoryoperator= (const Directory &)
 Assignment operator.

Static Public Member Functions

static Directory root ()
 Returns a root directory object.
static std::string tmp ()
 A convenience function for constructing a filename for writeable().


Detailed Description

An encapsulation of a file system directory which allows for iterating through the set of contained files.

See also:
G::Path, G::FileSystem, G::File

Definition at line 46 of file gdirectory.h.


Constructor & Destructor Documentation

G::Directory::Directory (  ) 

Default constructor for the current directory.

Definition at line 27 of file gdirectory.cpp.

Referenced by root().

G::Directory::Directory ( const char *  path  )  [explicit]

Constructor.

Definition at line 39 of file gdirectory.cpp.

G::Directory::Directory ( const Path path  )  [explicit]

Constructor.

Definition at line 49 of file gdirectory.cpp.

G::Directory::Directory ( const std::string &  path  )  [explicit]

Constructor.

Definition at line 44 of file gdirectory.cpp.

G::Directory::~Directory (  ) 

Destructor.

Definition at line 54 of file gdirectory.cpp.

G::Directory::Directory ( const Directory other  ) 

Copy constructor.

Definition at line 58 of file gdirectory.cpp.


Member Function Documentation

bool G::Directory::valid ( bool  for_creating_files = false  )  const

Returns true if the object represents a valid directory.

Does additional checks if the 'for-creating-files' parameter is true. But note that the answer is not definitive -- file creation may fail, even if valid() returns true. For a more accurate test use writeable().

Definition at line 39 of file gdirectory_unix.cpp.

References G::Path::str().

Referenced by G::DirectoryIteratorImp::isDir().

bool G::Directory::writeable ( std::string  probe_filename = tmp()  )  const

Tries to create and then delete an empty test file in the directory.

Returns true on success. Precondition: valid()

Definition at line 76 of file gdirectory_unix.cpp.

References G::Path::pathAppend(), G::Path::str(), and tmp().

G::Path G::Directory::path (  )  const

Returns the directory's path.

Definition at line 69 of file gdirectory.cpp.

Referenced by G::DirectoryIteratorImp::DirectoryIteratorImp().

G::Directory & G::Directory::operator= ( const Directory rhs  ) 

Assignment operator.

Definition at line 63 of file gdirectory.cpp.

References m_path.

G::Directory G::Directory::root (  )  [static]

Returns a root directory object.

For DOSy file systems this will not contain a drive part.

Definition at line 32 of file gdirectory.cpp.

References Directory(), s, and G::FileSystem::slash().

std::string G::Directory::tmp (  )  [static]

A convenience function for constructing a filename for writeable().

This is factored out so that client code can minimise the time spent with a privileged effective userid.

Definition at line 69 of file gdirectory_unix.cpp.

References G::DateTime::now().

Referenced by writeable().


The documentation for this class was generated from the following files:

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5