diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-05-16 00:53:30 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-05-16 00:54:29 +0300 |
commit | 4eed412140b37b3d967ab712f6d4feee36f6eb87 (patch) | |
tree | 7d0d453a46b9a879a14deed4da2384d99f8621a2 /include/winapi | |
parent | clang-format: SafeInt is no more (diff) | |
download | winapi-common-4eed412140b37b3d967ab712f6d4feee36f6eb87.tar.gz winapi-common-4eed412140b37b3d967ab712f6d4feee36f6eb87.zip |
File: add get_size/query_id
Diffstat (limited to 'include/winapi')
-rw-r--r-- | include/winapi/file.hpp | 37 |
1 files changed, 37 insertions, 0 deletions
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 <boost/functional/hash.hpp> + +#include <windows.h> + +#include <cstddef> +#include <functional> #include <string> #include <utility> 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<winapi::File::ID> { + 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 |