yat  0.14.5pre
Public Member Functions | List of all members
theplu::yat::utility::FileUtil Class Reference

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

#include <yat/utility/FileUtil.h>

Public Member Functions

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

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

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_errorif 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
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_errorif exists() throws.
std::invalid_argumentif bits contain other character than r, w, x, or d.

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

Generated on Tue Sep 26 2017 02:33:31 for yat by  doxygen 1.8.5