diff options
Diffstat (limited to 'src/common/file_util.h')
| -rw-r--r-- | src/common/file_util.h | 24 |
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 | ||
| 22 | namespace FileUtil { | 22 | namespace Common::FS { |
| 23 | 23 | ||
| 24 | // User paths for GetUserPath | 24 | // User paths for GetUserPath |
| 25 | enum class UserPath { | 25 | enum 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 | ||
| 208 | template <typename T> | ||
| 209 | void 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: | ||
| 291 | template <typename T> | ||
| 292 | void 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 | } | ||