yat  0.18pre
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.

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.

True if file exists, false otherwise.
IO_errorif underlying stat(2) call fails in other ways than that file does not exist.
See also
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.

true if file exists
See also
New in yat 0.5
FileUtil& theplu::yat::utility::FileUtil::operator= ( const FileUtil )

assignment operator

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.

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.
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.
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 Sun Sep 27 2020 02:26:14 for yat by  doxygen 1.8.11