aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/utils
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-05-15 21:22:50 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-05-15 21:22:50 +0300
commitf6af7c442df3e569492ced730e70d1bc72356c5e (patch)
treebd18c18acbc131bd43de99c9f03f698eff479a82 /src/utils
parentworkflows/ci: build using VS 2015 also (diff)
downloadwinapi-debug-f6af7c442df3e569492ced730e70d1bc72356c5e.tar.gz
winapi-debug-f6af7c442df3e569492ced730e70d1bc72356c5e.zip
get rid of SafeInt
Diffstat (limited to '')
-rw-r--r--src/utils/file.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/utils/file.cpp b/src/utils/file.cpp
index fb106ec..3f37cfc 100644
--- a/src/utils/file.cpp
+++ b/src/utils/file.cpp
@@ -5,12 +5,12 @@
#include <pdb/all.hpp>
-#include <SafeInt.hpp>
#include <boost/nowide/convert.hpp>
#include <windows.h>
#include <cstddef>
+#include <cstdint>
#include <stdexcept>
#include <string>
@@ -34,12 +34,9 @@ std::size_t get_size(const std::string& path) {
if (!GetFileSizeEx(handle.get(), &size))
throw error::windows(GetLastError(), "GetFileSizeEx");
- std::size_t result = 0;
-
- if (!SafeCast(size.QuadPart, result))
+ if (size.QuadPart < 0 || size.QuadPart > SIZE_MAX)
throw std::runtime_error{"invalid file size"};
-
- return result;
+ return static_cast<std::size_t>(size.QuadPart);
}
ID query_id(const std::string& path) {