A Directory represents a pathname that refers to a possibly non-existing directory. More...
#include <file.h>
Public Member Functions | |
Directory (const std::string &path) throw (FileError) | |
Constructor, note that path may not exist. | |
Directory (const File &file) throw (FileError) | |
Equivalent to Directory(file.str());. | |
~Directory () | |
Destructor. | |
const std::vector< std::string > & | files () const throw (FileError) |
Return files (only filenames, not absolute paths) in the directory. | |
std::string | file (const std::string &filename) const |
Return str()+"/"+filename, i.e. | |
std::string | tempfile (const std::string &prefix) const throw (FileError) |
Return str()+"/"+temp_filename, where temp_filename starts with prefix, i.e. | |
std::string | tempdir (const std::string &prefix) const throw (FileError) |
Return str()+"/"+temp_dirname, where temp_dirname starts with prefix, i.e. | |
bool | cd () const throw (FileError) |
Change working directory. | |
void | walk (FileOperation *fileop=NULL, DirectoryOperation *dirop=NULL) |
Performs a walk through the filesystem starting from this directory. | |
Static Public Member Functions | |
static std::string | pwd () throw (FileError) |
Return absolute pathname of current working directory. | |
Private Member Functions | |
void | refresh () const throw (FileError) |
Updates private data members, exist_ and type_. | |
void | init () const throw (FileError) |
Private Attributes | |
std::vector< std::string > | files_ |
A Directory represents a pathname that refers to a possibly non-existing directory.
It is privately derived from File, relevant File members are available, in addition tot the files() member that retrieves the files in an existing directory.
File::exists, File::mkdir, File::path, File::str, File::realpath, File::relpath, File::last_modified, File::last_accessed, File::touch, File::chown, File::chgrp, File::chmod, File::rm, File::mv, File::rmfr
Definition at line 409 of file file.h.
Dv::Util::Directory::Directory | ( | const std::string & | path | ) | throw (FileError) |
Constructor, note that path may not exist.
Equivalent to Directory(file.str());.
Dv::Util::Directory::~Directory | ( | ) |
Destructor.
const std::vector<std::string>& Dv::Util::Directory::files | ( | ) | const throw (FileError) [inline] |
Return files (only filenames, not absolute paths) in the directory.
If the directory does not exist, the vector is empty. The directory entries ``.'' and ``..'' are not included in the output of Dv::Util::Directory::files().
std::string Dv::Util::Directory::file | ( | const std::string & | filename | ) | const |
Return str()+"/"+filename, i.e.
a pathname for a filename in directory.
std::string Dv::Util::Directory::tempfile | ( | const std::string & | prefix | ) | const throw (FileError) |
Return str()+"/"+temp_filename, where temp_filename starts with prefix, i.e.
a pathname for a temporary file in the directory.
prefix | of name of file to be created in this directory. |
std::string Dv::Util::Directory::tempdir | ( | const std::string & | prefix | ) | const throw (FileError) |
Return str()+"/"+temp_dirname, where temp_dirname starts with prefix, i.e.
a pathname for a temporary subdirectory in the directory.
prefix | of name of file to be created in this directory. |
bool Dv::Util::Directory::cd | ( | ) | const throw (FileError) |
Change working directory.
static std::string Dv::Util::Directory::pwd | ( | ) | throw (FileError) [static] |
Return absolute pathname of current working directory.
void Dv::Util::Directory::walk | ( | FileOperation * | fileop = NULL , |
|
DirectoryOperation * | dirop = NULL | |||
) |
Performs a walk through the filesystem starting from this directory.
The operation executes for each file (special files included, except directories) it encounters the operation fileop(), while for each directory a call to dirop() is done. Files and/or directories with ``permission denied'' for the user running the program are skipped.
fileop | NULL or pointer to an instance of a subclass of FileOperation. | |
dirop | NULL or pointer to an instance of a subclass of DirectoryOperation. |
void Dv::Util::Directory::refresh | ( | ) | const throw (FileError) [private, virtual] |
Updates private data members, exist_ and type_.
Reimplemented from Dv::Util::File.
Referenced by files().
void Dv::Util::Directory::init | ( | ) | const throw (FileError) [private] |
std::vector<std::string> Dv::Util::Directory::files_ [private] |
dvutil-1.0.10 | [ 5 December, 2009] |