file_utils.cpp
1#include "itch/common/file_utils.hpp"2#include <filesystem>3#include <stdexcept>45namespace itch {6void reject_same_file(const std::string& a, const std::string& b) {7 if (a.empty() || b.empty()) {8 return;9 }10 namespace fs = std::filesystem;11 std::error_code ec;12 const bool equivalent = fs::equivalent(a, b, ec);13 if ((!ec && equivalent) || fs::weakly_canonical(a) == fs::weakly_canonical(b)) {14 throw std::runtime_error("file paths must be distinct: " + a + " and " + b);15 }16}17} // namespace itch