// Copyright Epic Games, Inc. All Rights Reserved. #include "localrefpolicy.h" #include #include #include namespace zen { DataRootLocalRefPolicy::DataRootLocalRefPolicy(const std::filesystem::path& DataRoot) : m_CanonicalRoot(std::filesystem::weakly_canonical(DataRoot).string()) { } void DataRootLocalRefPolicy::ValidatePath(const std::filesystem::path& Path) const { std::filesystem::path CanonicalFile = std::filesystem::weakly_canonical(Path); std::string FileStr = CanonicalFile.string(); if (FileStr.size() < m_CanonicalRoot.size() || FileStr.compare(0, m_CanonicalRoot.size(), m_CanonicalRoot) != 0) { throw zen::invalid_argument("local file reference '{}' is outside allowed data root", CanonicalFile); } } } // namespace zen