diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2021-05-15 21:22:50 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2021-05-15 21:22:50 +0300 |
commit | f6af7c442df3e569492ced730e70d1bc72356c5e (patch) | |
tree | bd18c18acbc131bd43de99c9f03f698eff479a82 /src/utils | |
parent | workflows/ci: build using VS 2015 also (diff) | |
download | winapi-debug-f6af7c442df3e569492ced730e70d1bc72356c5e.tar.gz winapi-debug-f6af7c442df3e569492ced730e70d1bc72356c5e.zip |
get rid of SafeInt
Diffstat (limited to '')
-rw-r--r-- | src/utils/file.cpp | 9 |
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) { |