summaryrefslogtreecommitdiff
path: root/src/common/file_util.h
diff options
context:
space:
mode:
authorGravatar bunnei2018-04-29 21:47:28 -0400
committerGravatar GitHub2018-04-29 21:47:28 -0400
commitb3962e7d1e585f33461f1a0f11c825cf261f6c7d (patch)
tree5396d4f28614f5b346a21776935597ec466f117f /src/common/file_util.h
parentMerge pull request #421 from Subv/sh_pred3 (diff)
parentfile_util: Make move constructor/assignment operator and related functions no... (diff)
downloadyuzu-b3962e7d1e585f33461f1a0f11c825cf261f6c7d.tar.gz
yuzu-b3962e7d1e585f33461f1a0f11c825cf261f6c7d.tar.xz
yuzu-b3962e7d1e585f33461f1a0f11c825cf261f6c7d.zip
Merge pull request #423 from lioncash/file
file_util: Minor changes to IOFile
Diffstat (limited to 'src/common/file_util.h')
-rw-r--r--src/common/file_util.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 4c11849ee..fc6b3ea46 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -160,10 +160,10 @@ public:
160 160
161 ~IOFile(); 161 ~IOFile();
162 162
163 IOFile(IOFile&& other); 163 IOFile(IOFile&& other) noexcept;
164 IOFile& operator=(IOFile&& other); 164 IOFile& operator=(IOFile&& other) noexcept;
165 165
166 void Swap(IOFile& other); 166 void Swap(IOFile& other) noexcept;
167 167
168 bool Open(const std::string& filename, const char openmode[]); 168 bool Open(const std::string& filename, const char openmode[]);
169 bool Close(); 169 bool Close();
@@ -202,11 +202,15 @@ public:
202 return items_written; 202 return items_written;
203 } 203 }
204 204
205 size_t ReadBytes(void* data, size_t length) { 205 template <typename T>
206 size_t ReadBytes(T* data, size_t length) {
207 static_assert(std::is_trivially_copyable<T>(), "T must be trivially copyable");
206 return ReadArray(reinterpret_cast<char*>(data), length); 208 return ReadArray(reinterpret_cast<char*>(data), length);
207 } 209 }
208 210
209 size_t WriteBytes(const void* data, size_t length) { 211 template <typename T>
212 size_t WriteBytes(const T* data, size_t length) {
213 static_assert(std::is_trivially_copyable<T>(), "T must be trivially copyable");
210 return WriteArray(reinterpret_cast<const char*>(data), length); 214 return WriteArray(reinterpret_cast<const char*>(data), length);
211 } 215 }
212 216