theplu::yat::utility::FileUtil Class Reference

Checking file/directory existence and access permissions. More...

#include <yat/utility/FileUtil.h>

List of all members.

Public Member Functions

 FileUtil (const std::string &path)
 Constructor, copies path only.
 FileUtil (const FileUtil &)
 Copies the path.
int permissions (const std::string &bits) const
 Check file/directory permissions.
bool exists (void) const
 Check whether file exists.
bool lexists (void) const
const std::string & path (void) const
 Get path associated with the object.
FileUtiloperator= (const FileUtil &)
 assignment operator


Detailed Description

Checking file/directory existence and access permissions.

FileUtil is a wrapper to access(2) and stat(2).


Constructor & Destructor Documentation

theplu::yat::utility::FileUtil::FileUtil ( const FileUtil  ) 

Copies the path.

Since:
New in yat 0.6


Member Function Documentation

int theplu::yat::utility::FileUtil::permissions ( const std::string &  bits  )  const

Check file/directory permissions.

Check if access permissions match mode. mode must be given as r, w, x, d, or combinations of these letters. The check is performed at call time.

Note:
Checking permissions on a non-existent file will match the permissions against the parent directory, but only the parent directory. This means that when the parent directory does not exist then fail is returned.
Returns:
On success (all requested permissions granted), zero is returned. On error (at least one bit in mode asked for a permission that is denied, or some other error occurred), -1 is returned, and errno is set appropriately.
Exceptions:
IO_error if exists() throws.
std::invalid_argument if bits contain other character than r, w, x, or d.

bool theplu::yat::utility::FileUtil::exists ( void   )  const

Check whether file exists.

The check for the file is done when calling this function.

Returns:
True if file exists, false otherwise.
Exceptions:
IO_error if underlying stat(2) call fails in other ways than that file does not exist.
See also:
stat(2)

bool theplu::yat::utility::FileUtil::lexists ( void   )  const

Same as exists(void) but uses lstat rather than stat. That implies that the function will return true also if path is a broken link.

Returns:
true if file exists
See also:
lstat(2)
Since:
New in yat 0.5

FileUtil& theplu::yat::utility::FileUtil::operator= ( const FileUtil  ) 

assignment operator

Since:
New in yat 0.6


The documentation for this class was generated from the following file:

Generated on Tue Jan 18 02:21:18 2011 for yat by  doxygen 1.5.5