From 4eed412140b37b3d967ab712f6d4feee36f6eb87 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sun, 16 May 2021 00:53:30 +0300 Subject: File: add get_size/query_id --- include/winapi/file.hpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'include') diff --git a/include/winapi/file.hpp b/include/winapi/file.hpp index b9688e9..78187d9 100644 --- a/include/winapi/file.hpp +++ b/include/winapi/file.hpp @@ -8,15 +8,34 @@ #include "handle.hpp" #include "path.hpp" +#include + +#include + +#include +#include #include #include namespace winapi { +bool operator==(const FILE_ID_128& a, const FILE_ID_128& b); + class File : private Handle { public: + struct ID { + const FILE_ID_INFO impl; + + bool operator==(const ID& other) const { + return impl.VolumeSerialNumber == other.impl.VolumeSerialNumber && + impl.FileId == other.impl.FileId; + } + }; + static Handle open_r(const std::string&); static Handle open_r(const CanonicalPath&); + static Handle open_read_attributes(const std::string&); + static Handle open_read_attributes(const CanonicalPath&); static Handle open_w(const std::string&); static Handle open_w(const CanonicalPath&); @@ -29,6 +48,24 @@ public: using Handle::read; using Handle::write; + + std::size_t get_size() const; + + ID query_id() const; }; } // namespace winapi + +namespace std { + +template <> +struct hash { + std::size_t operator()(const winapi::File::ID& id) const { + std::size_t seed = 0; + boost::hash_combine(seed, id.impl.VolumeSerialNumber); + boost::hash_combine(seed, id.impl.FileId.Identifier); + return seed; + } +}; + +} // namespace std -- cgit v1.2.3