fs: Reimplement path resolving using std::filesystem::weakly_canonical

This commit is contained in:
Eladash 2021-11-20 10:44:33 +02:00 committed by Ivan
parent 8c9090fd03
commit 0c4b2ff06b
6 changed files with 45 additions and 21 deletions

View file

@ -4,6 +4,7 @@
#include "Crypto/sha1.h"
#include <unordered_map>
#include <filesystem>
#include <algorithm>
#include <cstring>
#include <map>
@ -1822,6 +1823,20 @@ bool fs::remove_all(const std::string& path, bool remove_root)
return true;
}
std::string fs::resolve_path(std::string_view path)
{
std::error_code ec{};
const auto result = std::filesystem::weakly_canonical(std::filesystem::path(path), ec);
if (ec)
{
g_tls_error = error::inval;
return {};
}
return result.string();
}
u64 fs::get_dir_size(const std::string& path, u64 rounding_alignment)
{
u64 result = 0;