fs/CheckFile: use FileInfo(Path) instead of GetFileInfo()
This commit is contained in:
parent
4dc7d1c0cd
commit
37c4470f10
@ -31,30 +31,27 @@
|
|||||||
|
|
||||||
void
|
void
|
||||||
CheckDirectoryReadable(Path path_fs)
|
CheckDirectoryReadable(Path path_fs)
|
||||||
{
|
try {
|
||||||
Error error;
|
const auto path_utf8 = path_fs.ToUTF8();
|
||||||
|
|
||||||
FileInfo fi;
|
|
||||||
if (!GetFileInfo(path_fs, fi, error)) {
|
|
||||||
LogError(error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
const FileInfo fi(path_fs);
|
||||||
if (!fi.IsDirectory()) {
|
if (!fi.IsDirectory()) {
|
||||||
const auto path_utf8 = path_fs.ToUTF8();
|
|
||||||
FormatError(config_domain,
|
FormatError(config_domain,
|
||||||
"Not a directory: %s", path_utf8.c_str());
|
"Not a directory: %s", path_utf8.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
const auto x = AllocatedPath::Build(path_fs,
|
try {
|
||||||
PathTraitsFS::CURRENT_DIRECTORY);
|
const auto x = AllocatedPath::Build(path_fs,
|
||||||
if (!GetFileInfo(x, fi) && errno == EACCES) {
|
PathTraitsFS::CURRENT_DIRECTORY);
|
||||||
const auto path_utf8 = path_fs.ToUTF8();
|
const FileInfo fi2(x);
|
||||||
FormatError(config_domain,
|
} catch (const std::system_error &e) {
|
||||||
"No permission to traverse (\"execute\") directory: %s",
|
if (e.code().category() == std::system_category() &&
|
||||||
path_utf8.c_str());
|
e.code().value() == EACCES)
|
||||||
|
FormatError(config_domain,
|
||||||
|
"No permission to traverse (\"execute\") directory: %s",
|
||||||
|
path_utf8.c_str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -66,4 +63,6 @@ CheckDirectoryReadable(Path path_fs)
|
|||||||
"No permission to read directory: %s",
|
"No permission to read directory: %s",
|
||||||
path_fs.ToUTF8().c_str());
|
path_fs.ToUTF8().c_str());
|
||||||
}
|
}
|
||||||
|
} catch (const std::runtime_error &e) {
|
||||||
|
LogError(e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user