aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/utils/file.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/utils/file.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/utils/file.cpp b/src/utils/file.cpp
index 4150685..f013d90 100644
--- a/src/utils/file.cpp
+++ b/src/utils/file.cpp
@@ -37,15 +37,12 @@ namespace pdb
if (!GetFileSizeEx(handle.get(), &size))
throw error::windows(GetLastError());
- try
- {
- const msl::utilities::SafeInt<decltype(size.QuadPart)> safe_size{size.QuadPart};
- return static_cast<std::size_t>(safe_size);
- }
- catch (const msl::utilities::SafeIntException&)
- {
- throw std::range_error{"invalid file size"};
- }
+ std::size_t result = 0;
+
+ if (!msl::utilities::SafeCast(size.QuadPart, result))
+ throw std::runtime_error{"unsupported file size"};
+
+ return result;
}
}
}