Handle permission error. parrent -> parent

This commit is contained in:
goeiecool9999 2022-09-08 16:02:50 +02:00 committed by klaas
parent fb789419c3
commit 9fc2d8b158

View File

@ -5,18 +5,20 @@ std::optional<fs::path> findPathCI(const fs::path& path)
{
if (fs::exists(path)) return path;
if (!path.has_parent_path()) return {};
auto parrentPath = path.parent_path();
if (!fs::exists(parrentPath))
auto parentPath = path.parent_path();
if (!fs::exists(parentPath))
{
auto tempParrentPath = findPathCI(parrentPath);
if (tempParrentPath.has_value())
parrentPath = std::move(tempParrentPath.value());
auto tempParentPath = findPathCI(parentPath);
if (tempParentPath.has_value())
parentPath = std::move(tempParentPath.value());
else
return {};
}
std::wstring fName = path.filename().wstring();
if (fs::exists(parrentPath))
for (auto&& dirEntry : fs::directory_iterator(parrentPath))
if (fs::exists(parentPath))
{
std::error_code listErr;
for (auto&& dirEntry: fs::directory_iterator(parentPath, listErr))
{
std::wstring dirFName = dirEntry.path().filename().wstring();
if (boost::iequals(dirFName, fName, std::locale::classic()))
@ -24,7 +26,10 @@ std::optional<fs::path> findPathCI(const fs::path& path)
return dirEntry;
}
}
return parrentPath / fName;
if (listErr)
return fName;
}
return parentPath / fName;
}
FileStream* FileStream::openFile(std::string_view path)