diff options
author | bunnei <bunneidev@gmail.com> | 2018-09-17 09:51:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-17 09:51:47 -0400 |
commit | 076add4ccddff3940e20fc320615e3d330f77119 (patch) | |
tree | bacabcfed8665974c276489509a1caa330ad36a2 /src/common/file_util.h | |
parent | 3be048e50a2090caf1eeeb2373c7524ecc177ce8 (diff) | |
parent | 63c2e32e207d31ecadd9022e1d7cd705c9febac8 (diff) |
Merge pull request #1326 from FearlessTobi/port-4182
Port #4182 from Citra: "Prefix all size_t with std::"
Diffstat (limited to 'src/common/file_util.h')
-rw-r--r-- | src/common/file_util.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h index 2f13d0b6b..24c1e413c 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -143,8 +143,9 @@ const std::string& GetExeDirectory(); std::string AppDataRoamingDirectory(); #endif -size_t WriteStringToFile(bool text_file, const std::string& str, const char* filename); -size_t ReadFileToString(bool text_file, const char* filename, std::string& str); +std::size_t WriteStringToFile(bool text_file, const std::string& str, const char* filename); + +std::size_t ReadFileToString(bool text_file, const char* filename, std::string& str); /** * Splits the filename into 8.3 format @@ -177,10 +178,10 @@ std::string_view RemoveTrailingSlash(std::string_view path); // Creates a new vector containing indices [first, last) from the original. template <typename T> -std::vector<T> SliceVector(const std::vector<T>& vector, size_t first, size_t last) { +std::vector<T> SliceVector(const std::vector<T>& vector, std::size_t first, std::size_t last) { if (first >= last) return {}; - last = std::min<size_t>(last, vector.size()); + last = std::min<std::size_t>(last, vector.size()); return std::vector<T>(vector.begin() + first, vector.begin() + first + last); } @@ -213,47 +214,47 @@ public: bool Close(); template <typename T> - size_t ReadArray(T* data, size_t length) const { + std::size_t ReadArray(T* data, std::size_t length) const { static_assert(std::is_trivially_copyable_v<T>, "Given array does not consist of trivially copyable objects"); if (!IsOpen()) { - return std::numeric_limits<size_t>::max(); + return std::numeric_limits<std::size_t>::max(); } return std::fread(data, sizeof(T), length, m_file); } template <typename T> - size_t WriteArray(const T* data, size_t length) { + std::size_t WriteArray(const T* data, std::size_t length) { static_assert(std::is_trivially_copyable_v<T>, "Given array does not consist of trivially copyable objects"); if (!IsOpen()) { - return std::numeric_limits<size_t>::max(); + return std::numeric_limits<std::size_t>::max(); } return std::fwrite(data, sizeof(T), length, m_file); } template <typename T> - size_t ReadBytes(T* data, size_t length) const { + std::size_t ReadBytes(T* data, std::size_t length) const { static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable"); return ReadArray(reinterpret_cast<char*>(data), length); } template <typename T> - size_t WriteBytes(const T* data, size_t length) { + std::size_t WriteBytes(const T* data, std::size_t length) { static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable"); return WriteArray(reinterpret_cast<const char*>(data), length); } template <typename T> - size_t WriteObject(const T& object) { + std::size_t WriteObject(const T& object) { static_assert(!std::is_pointer_v<T>, "WriteObject arguments must not be a pointer"); return WriteArray(&object, 1); } - size_t WriteString(const std::string& str) { + std::size_t WriteString(const std::string& str) { return WriteArray(str.c_str(), str.length()); } |