fs/DirectoryReader: use C++ exceptions instead of class Error

This commit is contained in:
Max Kellermann
2015-12-29 12:41:45 +01:00
parent 826a654c95
commit f3503e0026
12 changed files with 79 additions and 76 deletions

View File

@@ -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());
}
}