Deepsolver
Classes | Static Public Member Functions
Deepsolver::Directory Class Reference

The wrapper for directory operations. More...

List of all members.

Classes

class  Iterator
 The iterator over the files and subdirectories. More...

Static Public Member Functions

static bool empty (const std::string &path)
 FIXME.
static void ensureExists (const std::string &path)
 Checks if the directory is exist and creates it it otherwise.
static bool ensureExistsAndEmpty (const std::string &name, bool needEraseContent=0)
 Creates directory and/or makes it empty.
static std::auto_ptr< Iteratorenumerate (const std::string &path)
 Creates the iterator over the files in the directory.
static void eraseContent (const std::string &name)
static bool isExist (const std::string &path)
 Checks if the directory exists.
static std::string mixNameComponents (const std::string &part1, const std::string &part2)
 Combines two parts of UNIX path.
static void remove (const std::string &name)
 Removes an empty directory.

Detailed Description

This class wraps mostly often used operations with directories in files system. Its generally purposed to take care over the error code returned by system calls and throw SystemException in case of problems.

See also:
File SystemException

Member Function Documentation

void Directory::ensureExists ( const std::string &  path) [static]

This method checks if the directory is exist and in case it isn't it will be created. The method throws SystemException if there are problems to check the directory or create it.

bool Directory::ensureExistsAndEmpty ( const std::string &  name,
bool  needEraseContent = 0 
) [static]
Returns:
Non-zero if directory is empty, with eraseContent set to 1 always returns non-zero
std::auto_ptr< Directory::Iterator > Directory::enumerate ( const std::string &  path) [static]

This method creates the iterator prepared for enumeration of all files and directories inside of the directory given by path. If the directory is inaccessible for reading the SystemException will be thrown.

Parameters:
[in]pathThe name of the directory to enumerate files in
Returns:
The auto_ptr<> to the prepared iterator
DEEPSOLVER_BEGIN_NAMESPACE bool Directory::isExist ( const std::string &  path) [static]

This method checks if the file system has the required entry and it is a directory by calling stat() system call. It never throes SystemException. This method returns zero even in case the directory is actually present but it existence cannot be checked due to wrong permissions.

Returns:
Non-zero if the directory is present and zero otherwise
std::string Directory::mixNameComponents ( const std::string &  part1,
const std::string &  part2 
) [static]

FIXME

void Directory::remove ( const std::string &  name) [static]

FIXME