Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

Dv::Util::Directory Class Reference

A Directory represents a pathname that refers to a possibly non-existing directory. More...

#include <file.h>

Inheritance diagram for Dv::Util::Directory:

Inheritance graph
[legend]
Collaboration diagram for Dv::Util::Directory:

Collaboration graph
[legend]
List of all members.

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.
bool exists () const throw (FileError)
bool mkdir (int mode=0755) throw (FileError)
const char * path () const
std::string str () const
std::string realpath () const throw (FileError)
std::string relpath (const std::string &from) const throw (FileError)
std::string relpath () const throw (FileError)
time_t last_modified () const throw (FileError)
time_t last_accessed () const throw (FileError)
bool touch (int mode=0644) throw (FileError)
bool chown (uid_t uid) const throw (FileError)
bool chgrp (const char *groupname) const throw (FileError)
bool chmod (int mode=0755) throw (FileError)
bool rm () throw (FileError)
bool mv (const std::string &newpath) throw (FileError)
void rmfr () throw (FileError)

Static Public Member Functions

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_

Detailed Description

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.

The following File members are available also in 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 369 of file file.h.


Constructor & Destructor Documentation

Dv::Util::Directory::Directory const std::string &  path  )  throw (FileError)
 

Constructor, note that path may not exist.

Dv::Util::Directory::Directory const File file  )  throw (FileError)
 

Equivalent to Directory(file.str());.

Dv::Util::Directory::~Directory  ) 
 

Destructor.


Member Function Documentation

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 Directory::files(). Definition at line 384 of file file.h.

References Dv::Util::File::refresh().

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.

Parameters:
prefix of name of file to be created in this directory.
Returns:
the filename
Warning:
This function calls mkstemp() which will actually create the corresponding file.

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.

Parameters:
prefix of name of file to be created in this directory.
Returns:
the directoryname
Warning:
This function calls mkdtemp() which will actually create the corresponding directory.

bool Dv::Util::Directory::cd  )  const throw (FileError)
 

Change working directory.

std::string Dv::Util::Directory::pwd  )  throw (FileError) [static]
 

Return absolute pathname of current working directory.

void Dv::Util::Directory::refresh  )  const throw (FileError) [private, virtual]
 

Updates private data members, exist_ and type_.

Reimplemented from Dv::Util::File.

void Dv::Util::Directory::init  )  const throw (FileError) [private]
 

bool Dv::Util::File::exists  )  const throw (FileError) [inline]
 

See also:
File::exists
Definition at line 133 of file file.h.

bool Dv::Util::File::mkdir int  mode = 0755  )  throw (FileError)
 

See also:
File::mkdir

const char* Dv::Util::File::path  )  const [inline]
 

See also:
File::path
Definition at line 154 of file file.h.

std::string Dv::Util::File::str  )  const [inline]
 

See also:
File::str
Definition at line 140 of file file.h.

std::string Dv::Util::File::realpath  )  const throw (FileError)
 

See also:
File::realpath

std::string Dv::Util::File::relpath const std::string &  from  )  const throw (FileError)
 

See also:
File::relpath

std::string Dv::Util::File::relpath  )  const throw (FileError)
 

See also:
File::relpath

time_t Dv::Util::File::last_modified  )  const throw (FileError)
 

See also:
File::last_modified

time_t Dv::Util::File::last_accessed  )  const throw (FileError)
 

See also:
File::last_accessed

bool Dv::Util::File::touch int  mode = 0644  )  throw (FileError)
 

See also:
File::touch

bool Dv::Util::File::chown uid_t  uid  )  const throw (FileError)
 

See also:
File::chown

bool Dv::Util::File::chgrp const char *  groupname  )  const throw (FileError)
 

See also:
File::chgrp

bool Dv::Util::File::chmod int  mode = 0755  )  throw (FileError)
 

See also:
File::chmod

bool Dv::Util::File::rm  )  throw (FileError)
 

See also:
File::rm

bool Dv::Util::File::mv const std::string &  newpath  )  throw (FileError)
 

See also:
File::mv

void Dv::Util::File::rmfr  )  throw (FileError)
 

See also:
File::rmfr


Member Data Documentation

std::vector<std::string> Dv::Util::Directory::files_ [private]
 

Definition at line 451 of file file.h.


The documentation for this class was generated from the following file:
dvutil-0.13.15 [30 December, 2004]