summaryrefslogtreecommitdiff
path: root/src/common/file_util.h
diff options
context:
space:
mode:
authorGravatar Lioncash2020-08-15 08:33:16 -0400
committerGravatar Lioncash2020-08-16 06:52:40 -0400
commitc4ed791164df7e3e74042a37a62077b4dc4ade91 (patch)
tree12bbcc09d0db32a0b6b5dc1bc49245964486da63 /src/common/file_util.h
parentMerge pull request #4528 from lioncash/discard (diff)
downloadyuzu-c4ed791164df7e3e74042a37a62077b4dc4ade91.tar.gz
yuzu-c4ed791164df7e3e74042a37a62077b4dc4ade91.tar.xz
yuzu-c4ed791164df7e3e74042a37a62077b4dc4ade91.zip
common/fileutil: Convert namespace to Common::FS
Migrates a remaining common file over to the Common namespace, making it consistent with the rest of common files. This also allows for high-traffic FS related code to alias the filesystem function namespace as namespace FS = Common::FS; for more concise typing.
Diffstat (limited to 'src/common/file_util.h')
-rw-r--r--src/common/file_util.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 681b28137..8b587320f 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -19,7 +19,7 @@
19#include "common/string_util.h" 19#include "common/string_util.h"
20#endif 20#endif
21 21
22namespace FileUtil { 22namespace Common::FS {
23 23
24// User paths for GetUserPath 24// User paths for GetUserPath
25enum class UserPath { 25enum class UserPath {
@@ -204,6 +204,16 @@ enum class DirectorySeparator {
204 std::string_view path, 204 std::string_view path,
205 DirectorySeparator directory_separator = DirectorySeparator::ForwardSlash); 205 DirectorySeparator directory_separator = DirectorySeparator::ForwardSlash);
206 206
207// To deal with Windows being dumb at Unicode
208template <typename T>
209void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) {
210#ifdef _MSC_VER
211 fstream.open(Common::UTF8ToUTF16W(filename), openmode);
212#else
213 fstream.open(filename, openmode);
214#endif
215}
216
207// simple wrapper for cstdlib file functions to 217// simple wrapper for cstdlib file functions to
208// hopefully will make error checking easier 218// hopefully will make error checking easier
209// and make forgetting an fclose() harder 219// and make forgetting an fclose() harder
@@ -285,14 +295,4 @@ private:
285 std::FILE* m_file = nullptr; 295 std::FILE* m_file = nullptr;
286}; 296};
287 297
288} // namespace FileUtil 298} // namespace Common::FS
289
290// To deal with Windows being dumb at unicode:
291template <typename T>
292void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) {
293#ifdef _MSC_VER
294 fstream.open(Common::UTF8ToUTF16W(filename), openmode);
295#else
296 fstream.open(filename, openmode);
297#endif
298}