From f6af7c442df3e569492ced730e70d1bc72356c5e Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 15 May 2021 21:22:50 +0300 Subject: get rid of SafeInt --- src/utils/file.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/utils') 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 -#include #include #include #include +#include #include #include @@ -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(size.QuadPart); } ID query_id(const std::string& path) { -- cgit v1.2.3