aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/utils
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-05-16 01:21:58 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-05-16 01:21:58 +0300
commitde5c928779d69e22221d08c21ce3b5455157004e (patch)
tree50ac3106f4fd91c5c900540596bed8b1c5db807d /src/utils
parentuse error reporting from winapi-common (diff)
downloadwinapi-debug-de5c928779d69e22221d08c21ce3b5455157004e.tar.gz
winapi-debug-de5c928779d69e22221d08c21ce3b5455157004e.zip
export pdb::file to winapi-common's File
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/file.cpp64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/utils/file.cpp b/src/utils/file.cpp
deleted file mode 100644
index fdc695f..0000000
--- a/src/utils/file.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2017 Egor Tensin <Egor.Tensin@gmail.com>
-// This file is part of the "winapi-debug" project.
-// For details, see https://github.com/egor-tensin/winapi-debug.
-// Distributed under the MIT License.
-
-#include <pdb/all.hpp>
-
-#include <winapi/error.hpp>
-#include <winapi/utf8.hpp>
-
-#include <windows.h>
-
-#include <cstddef>
-#include <cstdint>
-#include <stdexcept>
-#include <string>
-
-namespace pdb {
-namespace file {
-
-std::size_t get_size(const std::string& path) {
- const Handle handle{CreateFileW(winapi::widen(path).c_str(),
- FILE_READ_ATTRIBUTES,
- FILE_SHARE_READ,
- NULL,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL,
- NULL)};
-
- if (handle.get() == INVALID_HANDLE_VALUE)
- throw winapi::error::windows(GetLastError(), "CreateFileW");
-
- LARGE_INTEGER size;
-
- if (!GetFileSizeEx(handle.get(), &size))
- throw winapi::error::windows(GetLastError(), "GetFileSizeEx");
-
- if (size.QuadPart < 0 || size.QuadPart > SIZE_MAX)
- throw std::runtime_error{"invalid file size"};
- return static_cast<std::size_t>(size.QuadPart);
-}
-
-ID query_id(const std::string& path) {
- const Handle handle{CreateFileW(winapi::widen(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 winapi::error::windows(GetLastError(), "CreateFileW");
-
- FILE_ID_INFO id;
-
- if (!GetFileInformationByHandleEx(handle.get(), FileIdInfo, &id, sizeof(id)))
- throw winapi::error::windows(GetLastError(), "GetFileInformationByHandleEx");
-
- return {id};
-}
-
-} // namespace file
-} // namespace pdb