summaryrefslogtreecommitdiff
path: root/src/common/file_util.h
diff options
context:
space:
mode:
authorGravatar David Marcec2018-08-11 10:35:47 +1000
committerGravatar David Marcec2018-08-11 10:35:47 +1000
commitb76ddb7647cbb390cce4143d91a1db171b0fa503 (patch)
treea6e2e334e82b035923c41458150604dd5fb31d65 /src/common/file_util.h
parentAdded IsUserRegistrationRequestPermitted (diff)
parentMerge pull request #1007 from MerryMage/dynarmic (diff)
downloadyuzu-b76ddb7647cbb390cce4143d91a1db171b0fa503.tar.gz
yuzu-b76ddb7647cbb390cce4143d91a1db171b0fa503.tar.xz
yuzu-b76ddb7647cbb390cce4143d91a1db171b0fa503.zip
Merge remote-tracking branch 'origin/master' into better-account
Diffstat (limited to 'src/common/file_util.h')
-rw-r--r--src/common/file_util.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 430dac41c..2711872ae 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -182,8 +182,12 @@ std::vector<T> SliceVector(const std::vector<T>& vector, size_t first, size_t la
182 return std::vector<T>(vector.begin() + first, vector.begin() + first + last); 182 return std::vector<T>(vector.begin() + first, vector.begin() + first + last);
183} 183}
184 184
185// Removes trailing slash, makes all '\\' into '/', and removes duplicate '/'. 185enum class DirectorySeparator { ForwardSlash, BackwardSlash, PlatformDefault };
186std::string SanitizePath(std::string_view path); 186
187// Removes trailing slash, makes all '\\' into '/', and removes duplicate '/'. Makes '/' into '\\'
188// depending if directory_separator is BackwardSlash or PlatformDefault and running on windows
189std::string SanitizePath(std::string_view path,
190 DirectorySeparator directory_separator = DirectorySeparator::ForwardSlash);
187 191
188// simple wrapper for cstdlib file functions to 192// simple wrapper for cstdlib file functions to
189// hopefully will make error checking easier 193// hopefully will make error checking easier
@@ -208,7 +212,7 @@ public:
208 212
209 template <typename T> 213 template <typename T>
210 size_t ReadArray(T* data, size_t length) const { 214 size_t ReadArray(T* data, size_t length) const {
211 static_assert(std::is_trivially_copyable<T>(), 215 static_assert(std::is_trivially_copyable_v<T>,
212 "Given array does not consist of trivially copyable objects"); 216 "Given array does not consist of trivially copyable objects");
213 217
214 if (!IsOpen()) { 218 if (!IsOpen()) {
@@ -220,7 +224,7 @@ public:
220 224
221 template <typename T> 225 template <typename T>
222 size_t WriteArray(const T* data, size_t length) { 226 size_t WriteArray(const T* data, size_t length) {
223 static_assert(std::is_trivially_copyable<T>(), 227 static_assert(std::is_trivially_copyable_v<T>,
224 "Given array does not consist of trivially copyable objects"); 228 "Given array does not consist of trivially copyable objects");
225 if (!IsOpen()) { 229 if (!IsOpen()) {
226 return std::numeric_limits<size_t>::max(); 230 return std::numeric_limits<size_t>::max();
@@ -231,19 +235,19 @@ public:
231 235
232 template <typename T> 236 template <typename T>
233 size_t ReadBytes(T* data, size_t length) const { 237 size_t ReadBytes(T* data, size_t length) const {
234 static_assert(std::is_trivially_copyable<T>(), "T must be trivially copyable"); 238 static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable");
235 return ReadArray(reinterpret_cast<char*>(data), length); 239 return ReadArray(reinterpret_cast<char*>(data), length);
236 } 240 }
237 241
238 template <typename T> 242 template <typename T>
239 size_t WriteBytes(const T* data, size_t length) { 243 size_t WriteBytes(const T* data, size_t length) {
240 static_assert(std::is_trivially_copyable<T>(), "T must be trivially copyable"); 244 static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable");
241 return WriteArray(reinterpret_cast<const char*>(data), length); 245 return WriteArray(reinterpret_cast<const char*>(data), length);
242 } 246 }
243 247
244 template <typename T> 248 template <typename T>
245 size_t WriteObject(const T& object) { 249 size_t WriteObject(const T& object) {
246 static_assert(!std::is_pointer<T>::value, "Given object is a pointer"); 250 static_assert(!std::is_pointer_v<T>, "WriteObject arguments must not be a pointer");
247 return WriteArray(&object, 1); 251 return WriteArray(&object, 1);
248 } 252 }
249 253