diff options
| -rw-r--r-- | src/common/file_util.cpp | 4 | ||||
| -rw-r--r-- | src/common/file_util.h | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 740310807..d8812837e 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp | |||
| @@ -525,7 +525,7 @@ void CopyDir(const std::string& source_path, const std::string& dest_path) { | |||
| 525 | #endif | 525 | #endif |
| 526 | } | 526 | } |
| 527 | 527 | ||
| 528 | std::string GetCurrentDir() { | 528 | std::optional<std::string> GetCurrentDir() { |
| 529 | // Get the current working directory (getcwd uses malloc) | 529 | // Get the current working directory (getcwd uses malloc) |
| 530 | #ifdef _WIN32 | 530 | #ifdef _WIN32 |
| 531 | wchar_t* dir; | 531 | wchar_t* dir; |
| @@ -535,7 +535,7 @@ std::string GetCurrentDir() { | |||
| 535 | if (!(dir = getcwd(nullptr, 0))) { | 535 | if (!(dir = getcwd(nullptr, 0))) { |
| 536 | #endif | 536 | #endif |
| 537 | LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: {}", GetLastErrorMsg()); | 537 | LOG_ERROR(Common_Filesystem, "GetCurrentDirectory failed: {}", GetLastErrorMsg()); |
| 538 | return nullptr; | 538 | return {}; |
| 539 | } | 539 | } |
| 540 | #ifdef _WIN32 | 540 | #ifdef _WIN32 |
| 541 | std::string strDir = Common::UTF16ToUTF8(dir); | 541 | std::string strDir = Common::UTF16ToUTF8(dir); |
diff --git a/src/common/file_util.h b/src/common/file_util.h index c325f5b49..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, | |||
| 118 | bool DeleteDirRecursively(const std::string& directory, unsigned int recursion = 256); | 119 | bool DeleteDirRecursively(const std::string& directory, unsigned int recursion = 256); |
| 119 | 120 | ||
| 120 | // Returns the current directory | 121 | // Returns the current directory |
| 121 | std::string GetCurrentDir(); | 122 | std::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) |
| 124 | void CopyDir(const std::string& source_path, const std::string& dest_path); | 125 | void CopyDir(const std::string& source_path, const std::string& dest_path); |