fs/DirectoryReader: use C++ exceptions instead of class Error
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user