diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/file.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/utils/file.cpp b/src/utils/file.cpp index f013d90..dba8a38 100644 --- a/src/utils/file.cpp +++ b/src/utils/file.cpp @@ -44,5 +44,31 @@ namespace pdb return result; } + + ID query_id(const std::string& path) + { + const Handle handle{CreateFileA( + path.c_str(), + FILE_READ_ATTRIBUTES, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL)}; + + if (handle.get() == INVALID_HANDLE_VALUE) + throw error::windows(GetLastError()); + + ID id; + + if (!GetFileInformationByHandleEx( + handle.get(), + FileIdInfo, + &id, + sizeof(id))) + throw error::windows(GetLastError()); + + return id; + } } } |