fix: macOS 13 clang cannot hash std::filesystem::path

Work around another issue on macOS 13 where trying to build an
`std::unordered_set<std::filesystem::path>` results in an error
because `std::hash<std::filesystem::path>` is not provided.

Simply use the unix path instead, this should make no difference
and might even be slightly faster.
This commit is contained in:
Marcus Holland-Moritz 2025-03-19 22:29:44 +01:00
parent 9a9d5365b6
commit f7969109d5

View File

@ -359,14 +359,18 @@ bool filesystem_extractor_<LoggerPolicy>::extract(
} }
}; };
std::unordered_set<std::filesystem::path> matched_dirs; // Don't use an unordered_set<std::filesystem::path> here, this will break
// on macOS 13 due to clang not knowing how to hash std::filesystem::path.
std::unordered_set<std::string> matched_dirs;
if (matcher) { if (matcher) {
// Collect all directories that contain matching files to make sure
// we descend into them during the extraction walk below.
fs.walk([&](auto entry) { fs.walk([&](auto entry) {
if (!entry.inode().is_directory()) { if (!entry.inode().is_directory()) {
if (matcher->match(entry.unix_path())) { if (matcher->match(entry.unix_path())) {
while (auto parent = entry.parent()) { while (auto parent = entry.parent()) {
if (!matched_dirs.insert(parent->fs_path()).second) { if (!matched_dirs.insert(parent->unix_path()).second) {
break; break;
} }
entry = *parent; entry = *parent;
@ -385,16 +389,17 @@ bool filesystem_extractor_<LoggerPolicy>::extract(
auto inode = entry.inode(); auto inode = entry.inode();
if (matcher) { if (matcher) {
LOG_TRACE << "checking " << entry.unix_path(); auto const unix_path = entry.unix_path();
LOG_TRACE << "checking " << unix_path;
if (inode.is_directory()) { if (inode.is_directory()) {
if (!matched_dirs.contains(entry.fs_path())) { if (!matched_dirs.contains(unix_path)) {
LOG_TRACE << "skipping directory " << entry.fs_path(); LOG_TRACE << "skipping directory " << unix_path;
// no need to extract this directory // no need to extract this directory
return; return;
} }
} else { } else {
if (!matcher->match(entry.unix_path())) { if (!matcher->match(unix_path)) {
LOG_TRACE << "skipping " << entry.fs_path(); LOG_TRACE << "skipping " << unix_path;
// no match, skip this entry // no match, skip this entry
return; return;
} }