diff --git a/src/xenia/base/filesystem.cc b/src/xenia/base/filesystem.cc index b964bde2b..a24bbaf85 100644 --- a/src/xenia/base/filesystem.cc +++ b/src/xenia/base/filesystem.cc @@ -99,7 +99,7 @@ std::string CanonicalizePath(const std::string& original_path) { bool CreateParentFolder(const std::wstring& path) { auto fixed_path = xe::fix_path_separators(path, xe::kWPathSeparator); auto base_path = xe::find_base_path(fixed_path, xe::kWPathSeparator); - if (!PathExists(base_path)) { + if (!base_path.empty() && !PathExists(base_path)) { return CreateFolder(base_path); } else { return true; diff --git a/src/xenia/base/string.cc b/src/xenia/base/string.cc index 54a8d7ebf..ded97ffa5 100644 --- a/src/xenia/base/string.cc +++ b/src/xenia/base/string.cc @@ -262,7 +262,7 @@ std::wstring find_name_from_path(const std::wstring& path, wchar_t sep) { std::string find_base_path(const std::string& path, char sep) { auto last_slash = path.find_last_of(sep); if (last_slash == std::string::npos) { - return path; + return ""; } else if (last_slash == path.length() - 1) { auto prev_slash = path.find_last_of(sep, last_slash - 1); if (prev_slash == std::string::npos) { @@ -278,7 +278,7 @@ std::string find_base_path(const std::string& path, char sep) { std::wstring find_base_path(const std::wstring& path, wchar_t sep) { auto last_slash = path.find_last_of(sep); if (last_slash == std::wstring::npos) { - return path; + return L""; } else if (last_slash == path.length() - 1) { auto prev_slash = path.find_last_of(sep, last_slash - 1); if (prev_slash == std::wstring::npos) { diff --git a/src/xenia/gpu/trace_writer.cc b/src/xenia/gpu/trace_writer.cc index 819029b3d..e41f82643 100644 --- a/src/xenia/gpu/trace_writer.cc +++ b/src/xenia/gpu/trace_writer.cc @@ -32,7 +32,9 @@ bool TraceWriter::Open(const std::wstring& path, uint32_t title_id) { auto canonical_path = xe::to_absolute_path(path); auto base_path = xe::find_base_path(canonical_path); - xe::filesystem::CreateFolder(base_path); + if (!base_path.empty()) { + xe::filesystem::CreateFolder(base_path); + } file_ = xe::filesystem::OpenFile(canonical_path, "wb"); if (!file_) {