diff options
author | Max Kellermann <max@duempel.org> | 2015-12-29 12:41:45 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-12-29 12:56:26 +0100 |
commit | f3503e00264aaf5adb298c651f101c83d97600ef (patch) | |
tree | 2fd740a0bfa69407b60a9f5a6a909b3a81e4fb27 /src/fs/CheckFile.cxx | |
parent | 826a654c95c962c88f7eb803b50f6fd51504d273 (diff) |
fs/DirectoryReader: use C++ exceptions instead of class Error
Diffstat (limited to 'src/fs/CheckFile.cxx')
-rw-r--r-- | src/fs/CheckFile.cxx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/fs/CheckFile.cxx b/src/fs/CheckFile.cxx index e900fe9af..87064604a 100644 --- a/src/fs/CheckFile.cxx +++ b/src/fs/CheckFile.cxx @@ -25,6 +25,7 @@ #include "Path.hxx" #include "AllocatedPath.hxx" #include "DirectoryReader.hxx" +#include "system/Error.hxx" #include <errno.h> #include <sys/stat.h> @@ -58,11 +59,12 @@ CheckDirectoryReadable(Path path_fs) } #endif - const DirectoryReader reader(path_fs); - if (reader.HasFailed() && errno == EACCES) { - const auto path_utf8 = path_fs.ToUTF8(); - FormatError(config_domain, - "No permission to read directory: %s", - path_utf8.c_str()); + try { + const DirectoryReader reader(path_fs); + } catch (const std::system_error &e) { + if (IsAccessDenied(e)) + FormatError(config_domain, + "No permission to read directory: %s", + path_fs.ToUTF8().c_str()); } } |