Merge pull request #1 from goeiecool9999/case-inses

Handle permission error. parrent -> parent
This commit is contained in:
SSimco 2022-09-09 09:42:14 +03:00 committed by GitHub
commit 7b4dc86252
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,18 +4,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::string fName = path.filename().string();
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::string dirFName = dirEntry.path().filename().string();
if (boost::iequals(dirFName, fName))
@ -23,7 +25,9 @@ std::optional<fs::path> findPathCI(const fs::path& path)
return dirEntry;
}
}
return parrentPath / fName;
return fName;
}
return parentPath / fName;
}
FileStream* FileStream::openFile(std::string_view path)