From 2709a5d3e8f780973639df23f240b146bdb4c9fb Mon Sep 17 00:00:00 2001 From: Gliniak Date: Thu, 19 Sep 2024 22:08:42 +0200 Subject: [PATCH] [Emulator] Improvements to EmulatorWindow::RunTitle - Use reference instead of copy for provided path - Extended error logging for special cases --- src/xenia/app/emulator_window.cc | 26 +++++++++++++++++++------- src/xenia/app/emulator_window.h | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/xenia/app/emulator_window.cc b/src/xenia/app/emulator_window.cc index 22c0fc702..d5b861985 100644 --- a/src/xenia/app/emulator_window.cc +++ b/src/xenia/app/emulator_window.cc @@ -1902,15 +1902,27 @@ std::string EmulatorWindow::CanonicalizeFileExtension( return xe::utf8::lower_ascii(xe::path_to_utf8(path.extension())); } -xe::X_STATUS EmulatorWindow::RunTitle(std::filesystem::path path_to_file) { - bool titleExists = !std::filesystem::exists(path_to_file); +xe::X_STATUS EmulatorWindow::RunTitle( + const std::filesystem::path& path_to_file) { + std::error_code ec = {}; + bool titleExists = std::filesystem::exists(path_to_file, ec); - if (path_to_file.empty() || titleExists) { - char* log_msg = path_to_file.empty() - ? "Failed to launch title path is empty." - : "Failed to launch title path is invalid."; + if (path_to_file.empty() || !titleExists) { + std::string log_msg = + fmt::format("Failed to launch title path is {}.", + path_to_file.empty() ? "empty" : "invalid"); - XELOGE(log_msg); + if (!path_to_file.empty() && !titleExists) { + log_msg.append( + fmt::format("\nProvided Path: {}", xe::path_to_utf8(path_to_file))); + } + + if (ec) { + log_msg.append(fmt::format("\nExtended message info: {} ({:08X})", + ec.message(), ec.value())); + } + + XELOGE("{}", log_msg); imgui_drawer_.get()->ClearDialogs(); diff --git a/src/xenia/app/emulator_window.h b/src/xenia/app/emulator_window.h index 79c8aea3a..86bae14ca 100644 --- a/src/xenia/app/emulator_window.h +++ b/src/xenia/app/emulator_window.h @@ -82,7 +82,7 @@ class EmulatorWindow { void OnEmulatorInitialized(); - xe::X_STATUS RunTitle(std::filesystem::path path_to_file); + xe::X_STATUS RunTitle(const std::filesystem::path& path_to_file); void UpdateTitle(); void SetFullscreen(bool fullscreen); void ToggleFullscreen();