fix: material serialization
This commit is contained in:
@@ -201,6 +201,19 @@ std::filesystem::path AssetFS::GetCookedPathForFile(std::string_view vpath) cons
|
||||
return rawPath;
|
||||
}
|
||||
|
||||
std::optional<std::string> AssetFS::ToVirtualPath(const std::filesystem::path& fullPath) const {
|
||||
const std::filesystem::path normalized = fullPath.lexically_normal();
|
||||
for (const FSMount& mount : mounts) {
|
||||
const std::filesystem::path relative = normalized.lexically_relative(mount.root);
|
||||
if (relative.empty() || relative.is_absolute() || relative == "." ||
|
||||
relative == ".." || relative.generic_string().starts_with("../")) {
|
||||
continue;
|
||||
}
|
||||
return mount.scheme + "://" + relative.generic_string();
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> AssetFS::ReadFile(const std::filesystem::path& fullPath) {
|
||||
std::ifstream file(fullPath, std::ios::binary);
|
||||
if (!file) {
|
||||
|
||||
Reference in New Issue
Block a user