diff --git a/source/mijin/virtual_filesystem/filesystem.hpp b/source/mijin/virtual_filesystem/filesystem.hpp index b7ae653..54d70a3 100644 --- a/source/mijin/virtual_filesystem/filesystem.hpp +++ b/source/mijin/virtual_filesystem/filesystem.hpp @@ -11,6 +11,7 @@ #include #include #include "../io/stream.hpp" +#include "../util/hash.hpp" namespace fs = std::filesystem; @@ -49,6 +50,8 @@ private: public: PathReference(class FileSystemAdapter* adapter, fs::path path) noexcept : adapter_(adapter), path_(std::move(path)) {} + auto operator<=>(const PathReference& other) const noexcept = default; + [[nodiscard]] class FileSystemAdapter* getAdapter() const noexcept { return adapter_; } [[nodiscard]] const fs::path& getPath() const noexcept { return path_; } [[nodiscard]] inline FileInfo getInfo() const; @@ -129,4 +132,16 @@ inline std::string formatFileSize(std::size_t sizeInBytes) } // namespace mijin +template<> +struct std::hash +{ + std::size_t operator()(const mijin::PathReference& pathRef) const noexcept + { + std::size_t hash = 0; + mijin::hashCombine(hash, pathRef.getAdapter()); + mijin::hashCombine(hash, pathRef.getPath()); + return hash; + } +}; + #endif // !defined(MIJIN_VIRTUAL_FILESYSTEM_FILESYSTEM_HPP_INCLUDED)