E-MailRelay
|
An encapsulation of a file system directory that works with G::DirectoryIterator. More...
#include <gdirectory.h>
Public Member Functions | |
Directory () | |
Default constructor for the current directory. More... | |
Directory (const Path &path) | |
Constructor. More... | |
Directory (const std::string &path) | |
Constructor. More... | |
int | usable (bool for_creating_files=false) const |
Returns zero if the object represents a valid directory with permissions that dont disallow reading of any contained files. More... | |
bool | valid (bool for_creating_files=false) const |
Returns true iff usable() is zero. More... | |
bool | writeable (const std::string &probe_filename=tmp()) const |
Tries to create and then delete an empty test file in the directory. More... | |
Path | path () const |
Returns the directory's path, as passed in to the ctor. More... | |
Static Public Member Functions | |
static std::string | tmp () |
A convenience function for constructing a filename for writeable(). More... | |
An encapsulation of a file system directory that works with G::DirectoryIterator.
Definition at line 47 of file gdirectory.h.
G::Directory::Directory | ( | ) |
Default constructor for the current directory.
Definition at line 32 of file gdirectory.cpp.
|
explicit |
Constructor.
Definition at line 38 of file gdirectory.cpp.
|
explicit |
Constructor.
Definition at line 44 of file gdirectory.cpp.
G::Path G::Directory::path | ( | ) | const |
Returns the directory's path, as passed in to the ctor.
Definition at line 50 of file gdirectory.cpp.
|
static |
A convenience function for constructing a filename for writeable().
This is factored-out from writeable() into this public interface so that client code can minimise the time spent with a privileged effective userid.
Definition at line 55 of file gdirectory.cpp.
int G::Directory::usable | ( | bool | for_creating_files = false | ) | const |
Returns zero if the object represents a valid directory with permissions that dont disallow reading of any contained files.
Returns a non-zero errno otherwise.
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 usable() returns zero. For a more accurate test use writeable().
Definition at line 73 of file gdirectory_unix.cpp.
bool G::Directory::valid | ( | bool | for_creating_files = false | ) | const |
Returns true iff usable() is zero.
Definition at line 63 of file gdirectory.cpp.
bool G::Directory::writeable | ( | const 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 97 of file gdirectory_unix.cpp.