aboutsummaryrefslogtreecommitdiff
path: root/libbutl/filesystem.cxx
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.cxx
parentaa3583916131f21b6a936cd88c4b74a21151644f (diff)
Add ignore_error parameter for path_entry() and *_exists() functions
Diffstat (limited to 'libbutl/filesystem.cxx')
-rw-r--r--libbutl/filesystem.cxx20
1 files changed, 10 insertions, 10 deletions
diff --git a/libbutl/filesystem.cxx b/libbutl/filesystem.cxx
index 8c3abc4..da2f12c 100644
--- a/libbutl/filesystem.cxx
+++ b/libbutl/filesystem.cxx
@@ -75,34 +75,34 @@ using namespace std;
namespace butl
{
bool
- file_exists (const char* p, bool fl)
+ file_exists (const char* p, bool fl, bool ie)
{
- auto pe (path_entry (p, fl));
+ auto pe (path_entry (p, fl, ie));
return pe.first && (pe.second.type == entry_type::regular ||
(!fl && pe.second.type == entry_type::symlink));
}
bool
- entry_exists (const char* p, bool fl)
+ entry_exists (const char* p, bool fl, bool ie)
{
- return path_entry (p, fl).first;
+ return path_entry (p, fl, ie).first;
}
bool
- dir_exists (const char* p)
+ dir_exists (const char* p, bool ie)
{
- auto pe (path_entry (p, true));
+ auto pe (path_entry (p, true, ie));
return pe.first && pe.second.type == entry_type::directory;
}
#ifndef _WIN32
pair<bool, entry_stat>
- path_entry (const char* p, bool fl)
+ path_entry (const char* p, bool fl, bool ie)
{
struct stat s;
if ((fl ? stat (p, &s) : lstat (p, &s)) != 0)
{
- if (errno == ENOENT || errno == ENOTDIR)
+ if (errno == ENOENT || errno == ENOTDIR || ie)
return make_pair (false, entry_stat {entry_type::unknown, 0});
else
throw_generic_error (errno);
@@ -124,7 +124,7 @@ namespace butl
}
#else
pair<bool, entry_stat>
- path_entry (const char* p, bool)
+ path_entry (const char* p, bool, bool ie)
{
// A path like 'C:', while being a root path in our terminology, is not as
// such for Windows, that maintains current directory for each drive, and
@@ -157,7 +157,7 @@ namespace butl
if (_stat64 (p, &s) != 0)
{
- if (errno == ENOENT || errno == ENOTDIR)
+ if (errno == ENOENT || errno == ENOTDIR || ie)
return make_pair (false, entry_stat {entry_type::unknown, 0});
else
throw_generic_error (errno);