diff options
Diffstat (limited to 'src/utils')
-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) { |