aboutsummaryrefslogtreecommitdiff
path: root/libbutl/filesystem.mxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-10-04 15:19:47 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-10-04 15:19:47 +0300
commit50bdae2c0547051228361e439a72f8be62c3e936 (patch)
tree2d903defb50ee7ffdb70dd8eddeeb364f6e5734e /libbutl/filesystem.mxx
parentaa3583916131f21b6a936cd88c4b74a21151644f (diff)
Add ignore_error parameter for path_entry() and *_exists() functions
Diffstat (limited to 'libbutl/filesystem.mxx')
-rw-r--r--libbutl/filesystem.mxx41
1 files changed, 26 insertions, 15 deletions
diff --git a/libbutl/filesystem.mxx b/libbutl/filesystem.mxx
index b4caffe..bb78a4f 100644
--- a/libbutl/filesystem.mxx
+++ b/libbutl/filesystem.mxx
@@ -57,33 +57,41 @@ import butl.utility;
LIBBUTL_MODEXPORT namespace butl
{
// Return true if the path is to an existing regular file. Note that by
- // default this function follows symlinks.
+ // default this function follows symlinks. Underlying OS errors are reported
+ // by throwing std::system_error, unless ignore_error is true.
//
LIBBUTL_SYMEXPORT bool
- file_exists (const char*, bool follow_symlinks = true);
+ file_exists (const char*,
+ bool follow_symlinks = true,
+ bool ignore_error = false);
inline bool
- file_exists (const path& p, bool fs = true) {
- return file_exists (p.string ().c_str (), fs);}
+ file_exists (const path& p, bool fs = true, bool ie = false) {
+ return file_exists (p.string ().c_str (), fs, ie);}
// Return true if the path is to an existing directory. Note that this
- // function follows symlinks.
+ // function follows symlinks. Underlying OS errors are reported by throwing
+ // std::system_error, unless ignore_error is true.
//
LIBBUTL_SYMEXPORT bool
- dir_exists (const char*);
+ dir_exists (const char*, bool ignore_error = false);
inline bool
- dir_exists (const path& p) {return dir_exists (p.string ().c_str ());}
+ dir_exists (const path& p, bool ie = false) {
+ return dir_exists (p.string ().c_str (), ie);}
// Return true if the path is to an existing file system entry. Note that by
- // default this function doesn't follow symlinks.
+ // default this function doesn't follow symlinks. Underlying OS errors are
+ // reported by throwing std::system_error, unless ignore_error is true.
//
LIBBUTL_SYMEXPORT bool
- entry_exists (const char*, bool follow_symlinks = false);
+ entry_exists (const char*,
+ bool follow_symlinks = false,
+ bool ignore_error = false);
inline bool
- entry_exists (const path& p, bool fs = false) {
- return entry_exists (p.string ().c_str (), fs);}
+ entry_exists (const path& p, bool fs = false, bool ie = false) {
+ return entry_exists (p.string ().c_str (), fs, ie);}
// Filesystem entry type.
//
@@ -106,14 +114,17 @@ LIBBUTL_MODEXPORT namespace butl
// Return a flag indicating if the path is to an existing file system entry
// and its type if so. Note that by default this function doesn't follow
- // symlinks.
+ // symlinks. Underlying OS errors are reported by throwing std::system_error,
+ // unless ignore_error is true.
//
LIBBUTL_SYMEXPORT std::pair<bool, entry_stat>
- path_entry (const char*, bool follow_symlinks = false);
+ path_entry (const char*,
+ bool follow_symlinks = false,
+ bool ignore_error = false);
inline std::pair<bool, entry_stat>
- path_entry (const path& p, bool fs = false) {
- return path_entry (p.string ().c_str (), fs);}
+ path_entry (const path& p, bool fs = false, bool ie = false) {
+ return path_entry (p.string ().c_str (), fs, ie);}
// Return true if the directory is empty. Note that the path must exist
// and be a directory. This function follows symlinks.