summaryrefslogtreecommitdiff
path: root/src/common/file_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/file_util.h')
-rw-r--r--src/common/file_util.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 38cc7f059..cde7ddf2d 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -9,6 +9,7 @@
9#include <fstream> 9#include <fstream>
10#include <functional> 10#include <functional>
11#include <limits> 11#include <limits>
12#include <optional>
12#include <string> 13#include <string>
13#include <string_view> 14#include <string_view>
14#include <type_traits> 15#include <type_traits>
@@ -118,7 +119,7 @@ u64 ScanDirectoryTree(const std::string& directory, FSTEntry& parent_entry,
118bool DeleteDirRecursively(const std::string& directory, unsigned int recursion = 256); 119bool DeleteDirRecursively(const std::string& directory, unsigned int recursion = 256);
119 120
120// Returns the current directory 121// Returns the current directory
121std::string GetCurrentDir(); 122std::optional<std::string> GetCurrentDir();
122 123
123// Create directory and copy contents (does not overwrite existing files) 124// Create directory and copy contents (does not overwrite existing files)
124void CopyDir(const std::string& source_path, const std::string& dest_path); 125void CopyDir(const std::string& source_path, const std::string& dest_path);
@@ -146,9 +147,9 @@ const std::string& GetExeDirectory();
146std::string AppDataRoamingDirectory(); 147std::string AppDataRoamingDirectory();
147#endif 148#endif
148 149
149std::size_t WriteStringToFile(bool text_file, const std::string& str, const char* filename); 150std::size_t WriteStringToFile(bool text_file, const std::string& filename, std::string_view str);
150 151
151std::size_t ReadFileToString(bool text_file, const char* filename, std::string& str); 152std::size_t ReadFileToString(bool text_file, const std::string& filename, std::string& str);
152 153
153/** 154/**
154 * Splits the filename into 8.3 format 155 * Splits the filename into 8.3 format
@@ -257,8 +258,8 @@ public:
257 return WriteArray(&object, 1); 258 return WriteArray(&object, 1);
258 } 259 }
259 260
260 std::size_t WriteString(const std::string& str) { 261 std::size_t WriteString(std::string_view str) {
261 return WriteArray(str.c_str(), str.length()); 262 return WriteArray(str.data(), str.length());
262 } 263 }
263 264
264 bool IsOpen() const { 265 bool IsOpen() const {
@@ -286,8 +287,8 @@ private:
286template <typename T> 287template <typename T>
287void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) { 288void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) {
288#ifdef _MSC_VER 289#ifdef _MSC_VER
289 fstream.open(Common::UTF8ToUTF16W(filename).c_str(), openmode); 290 fstream.open(Common::UTF8ToUTF16W(filename), openmode);
290#else 291#else
291 fstream.open(filename.c_str(), openmode); 292 fstream.open(filename, openmode);
292#endif 293#endif
293} 294}