mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-06-03 14:14:59 -06:00
fix filesystem hang + date-tz
This commit is contained in:
parent
b0b906ac7f
commit
ce37cca1cd
@ -95,7 +95,7 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_rea
|
|||||||
std::scoped_lock lk{m_mutex};
|
std::scoped_lock lk{m_mutex};
|
||||||
path_parts.clear();
|
path_parts.clear();
|
||||||
auto current_path = host_path;
|
auto current_path = host_path;
|
||||||
while (!std::filesystem::exists(current_path)) {
|
while (!current_path.empty() && !std::filesystem::exists(current_path)) {
|
||||||
// We have probably cached this if it's a folder.
|
// We have probably cached this if it's a folder.
|
||||||
if (auto it = path_cache.find(current_path); it != path_cache.end()) {
|
if (auto it = path_cache.find(current_path); it != path_cache.end()) {
|
||||||
current_path = it->second;
|
current_path = it->second;
|
||||||
@ -104,38 +104,40 @@ std::filesystem::path MntPoints::GetHostPath(std::string_view path, bool* is_rea
|
|||||||
path_parts.emplace_back(current_path.filename());
|
path_parts.emplace_back(current_path.filename());
|
||||||
current_path = current_path.parent_path();
|
current_path = current_path.parent_path();
|
||||||
}
|
}
|
||||||
// We have found an anchor. Traverse parts we recoded and see if they
|
if (!current_path.empty()) {
|
||||||
// exist in filesystem but in different case.
|
// We have found an anchor. Traverse parts we recoded and see if they
|
||||||
auto guest_path = current_path;
|
// exist in filesystem but in different case.
|
||||||
while (!path_parts.empty()) {
|
auto guest_path = current_path;
|
||||||
const auto part = path_parts.back();
|
while (!path_parts.empty()) {
|
||||||
const auto add_match = [&](const auto& host_part) {
|
const auto part = path_parts.back();
|
||||||
current_path /= host_part;
|
const auto add_match = [&](const auto& host_part) {
|
||||||
guest_path /= part;
|
current_path /= host_part;
|
||||||
path_cache[guest_path] = current_path;
|
guest_path /= part;
|
||||||
path_parts.pop_back();
|
path_cache[guest_path] = current_path;
|
||||||
};
|
path_parts.pop_back();
|
||||||
// Can happen when the mismatch is in upper folder.
|
};
|
||||||
if (std::filesystem::exists(current_path / part)) {
|
// Can happen when the mismatch is in upper folder.
|
||||||
add_match(part);
|
if (std::filesystem::exists(current_path / part)) {
|
||||||
continue;
|
add_match(part);
|
||||||
}
|
|
||||||
const auto part_low = Common::ToLower(part.string());
|
|
||||||
bool found_match = false;
|
|
||||||
for (const auto& path : std::filesystem::directory_iterator(current_path)) {
|
|
||||||
const auto candidate = path.path().filename();
|
|
||||||
const auto filename = Common::ToLower(candidate.string());
|
|
||||||
// Check if a filename matches in case insensitive manner.
|
|
||||||
if (filename != part_low) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// We found a match, record the actual path in the cache.
|
const auto part_low = Common::ToLower(part.string());
|
||||||
add_match(candidate);
|
bool found_match = false;
|
||||||
found_match = true;
|
for (const auto& path : std::filesystem::directory_iterator(current_path)) {
|
||||||
break;
|
const auto candidate = path.path().filename();
|
||||||
}
|
const auto filename = Common::ToLower(candidate.string());
|
||||||
if (!found_match) {
|
// Check if a filename matches in case insensitive manner.
|
||||||
return std::optional<std::filesystem::path>({});
|
if (filename != part_low) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// We found a match, record the actual path in the cache.
|
||||||
|
add_match(candidate);
|
||||||
|
found_match = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!found_match) {
|
||||||
|
return std::optional<std::filesystem::path>({});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return std::optional<std::filesystem::path>(current_path);
|
return std::optional<std::filesystem::path>(current_path);
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "common/ntapi.h"
|
#include "common/ntapi.h"
|
||||||
#else
|
#else
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||||
#include <date/tz.h>
|
#include <date/tz.h>
|
||||||
#endif
|
#endif
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user