diff options
author | bunnei <bunneidev@gmail.com> | 2018-08-08 04:37:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 04:37:00 +0200 |
commit | 80cfd88e4ec5d2862227dedef5b9f709a8350319 (patch) | |
tree | d6fc13f86efe54ca4a6aec0c5a95ca56c5ca42cf | |
parent | Merge pull request #971 from DarkLordZach/mbedtls-2.12.0 (diff) | |
parent | file_util: Avoid sign-conversions in WriteArray() and ReadArray() (diff) | |
download | yuzu-80cfd88e4ec5d2862227dedef5b9f709a8350319.tar yuzu-80cfd88e4ec5d2862227dedef5b9f709a8350319.tar.gz yuzu-80cfd88e4ec5d2862227dedef5b9f709a8350319.tar.bz2 yuzu-80cfd88e4ec5d2862227dedef5b9f709a8350319.tar.lz yuzu-80cfd88e4ec5d2862227dedef5b9f709a8350319.tar.xz yuzu-80cfd88e4ec5d2862227dedef5b9f709a8350319.tar.zst yuzu-80cfd88e4ec5d2862227dedef5b9f709a8350319.zip |
-rw-r--r-- | src/common/file_util.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h index 28697d527..430dac41c 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -8,6 +8,7 @@ #include <cstdio> #include <fstream> #include <functional> +#include <limits> #include <string> #include <string_view> #include <type_traits> @@ -210,8 +211,9 @@ public: static_assert(std::is_trivially_copyable<T>(), "Given array does not consist of trivially copyable objects"); - if (!IsOpen()) - return -1; + if (!IsOpen()) { + return std::numeric_limits<size_t>::max(); + } return std::fread(data, sizeof(T), length, m_file); } @@ -220,8 +222,10 @@ public: size_t WriteArray(const T* data, size_t length) { static_assert(std::is_trivially_copyable<T>(), "Given array does not consist of trivially copyable objects"); - if (!IsOpen()) - return -1; + if (!IsOpen()) { + return std::numeric_limits<size_t>::max(); + } + return std::fwrite(data, sizeof(T), length, m_file); } |