#include <cxxtools/directory.h>
Public Types | |
| typedef DirectoryIterator | const_iterator |
Public Member Functions | |
| Directory (const std::string &path) | |
| Constructs a Directory object from the path path. | |
| Directory (const FileInfo &fi) | |
| Constructs a Directory object from a FileInfo object. | |
| Directory (const Directory &dir) | |
| Copy constructor. | |
| ~Directory () | |
| Destructor. | |
| Directory & | operator= (const Directory &dir) |
| Assignment operator. | |
| const std::string & | path () const |
| Returns the path of the directory. | |
| std::size_t | size () const |
| Returns the size of the directory in bytes. | |
| std::string | dirName () const |
| Returns the parent directory path. | |
| std::string | name () const |
| Returns the name of the directory excluding the path. | |
| void | remove () |
| Removes the directory. | |
| void | move (const std::string &to) |
| Moves the directory to the location given by to. | |
| const_iterator | begin () const |
| Returns an iterator to the first entry in the directory. | |
| const_iterator | end () const |
| Returns an iterator to the end of the directory entries. | |
Static Public Member Functions | |
| static Directory | create (const std::string &path) |
| Creates a new directory at the path given by path. | |
| static bool | exists (const std::string &path) |
| Returns true if a directory exists at path, or false otherwise. | |
| static void | chdir (const std::string &path) |
| Changes the current directory. | |
| static std::string | cwd () |
| Returns the current directory. | |
| static std::string | curdir () |
| Returns the string representng the current directory in path names. | |
| static std::string | updir () |
| Returns the string representng the upper directory in path names. | |
| static std::string | rootdir () |
| Returns the system root path. | |
| static std::string | tmpdir () |
| Returns the systems tmp directory. | |
| static std::string | sep () |
| Returns the string representng the separator in path names. | |
Protected Member Functions | |
| Directory () | |
| Default Constructor. | |
Iterator Example:
Directory d("/usr"); Directory::iterator it = d.begin(); while (it != d.end()) { std::cout << "name : " << *it << std::endl; ++it; }
| Directory | ( | const std::string & | path | ) | [explicit] |
If no directory exists at path, an exception of type DirectoryNotFound is thrown.
An exception of type DirectoryNotFound is thrown if the FileInfo does not represent a directory.
| const std::string& path | ( | ) | const |
This method may return a relative path, or a fully qualified one depending on how this object was constructed.
| std::string dirName | ( | ) | const |
This method might return an empty string if the node was created without a complete path. If the directory is located in the root directory of a unix file system, a slash ("/") is returned. A returned directory path always ends with a trailing path separator character. (A backslash in Windows and a slash in Unix, for example.)
| void remove | ( | ) |
This object will be invalid after calling this method.
| void move | ( | const std::string & | to | ) |
The Directory object will stay valid after this method was called and point to the moved directory.
| static std::string rootdir | ( | ) | [static] |
Returns "/" (root) on Linux, "c:\" on Windows
| static std::string tmpdir | ( | ) | [static] |
The environment variables TEMP and TMP are checked first. If not set, "/tmp" is returned if it exists. If none of the environment variables are set and the default system tmp directory does not exist, the current directory is returned.