fix(agc): take agc_pm4_replay's capture directory as a wide argument on Windows

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
orezraeyandClaude Opus 5.5 committed 2026-10-20 10:03:21 -03:00
1 parent 44e3389c88
commit ca1b18ba36
3 files changed
+31 -6

No files matched your search

@@ -2696,6 +2696,9 @@ add_executable(agc_pm4_replay EXCLUDE_FROM_ALL
target_include_directories(agc_pm4_replay PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(agc_pm4_replay PRIVATE libSceAgcDriver libc)
set_target_properties(agc_pm4_replay PROPERTIES CXX_EXTENSIONS OFF)
if(MINGW)
target_link_options(agc_pm4_replay PRIVATE -municode)
endif()
configure_windows_unwind(agc_pm4_replay)
if(BUILD_TESTING)
@@ -27,3 +27,12 @@ execute_process(COMMAND "${TOOL}" "${CAPTURE}/missing" RESULT_VARIABLE code OUTP
if(NOT code STREQUAL "2" OR NOT errors MATCHES "cannot open")
message(FATAL_ERROR "agc_pm4_replay exited with ${code} instead of 2 on a missing capture:\n${output}${errors}")
endif()
set(unicodeCapture "${CAPTURE}-ação-日本")
file(REMOVE_RECURSE "${unicodeCapture}")
file(COPY "${CAPTURE}/" DESTINATION "${unicodeCapture}")
execute_process(COMMAND "${TOOL}" "${unicodeCapture}" RESULT_VARIABLE code OUTPUT_VARIABLE output ERROR_VARIABLE errors)
file(REMOVE_RECURSE "${unicodeCapture}")
if(NOT code STREQUAL "1" OR NOT output MATCHES "unreleased 1\n")
message(FATAL_ERROR "agc_pm4_replay exited with ${code} on a copy of the capture under a non-ASCII path:\n${output}${errors}")
endif()
@@ -1,4 +1,5 @@
#include "Pm4Analysis.hpp"
#include <algorithm>
#include <cstdio>
#include <exception>
#include <filesystem>
@@ -14,15 +15,15 @@ int usage() {
return 2;
}
}
int main(int argc, char** argv) {
template <typename TChar>
int run(int argc, TChar** argv) {
constexpr std::string_view Full = "--full";
std::filesystem::path directory;
bool full = false;
for (int index = 1; index < argc; ++index) {
const std::string_view argument = argv[index];
if (argument == "--full") full = true;
else if (!argument.starts_with("-") && directory.empty()) directory = argument;
const std::basic_string_view<TChar> argument = argv[index];
if (std::ranges::equal(argument, Full)) full = true;
else if (!argument.starts_with(TChar('-')) && directory.empty()) directory = argument;
else return usage();
}
if (directory.empty()) return usage();
@@ -33,3 +34,15 @@ int main(int argc, char** argv) {
return 2;
}
}
}
#ifdef _WIN32
int wmain(int argc, wchar_t** argv) {
return run(argc, argv);
}
#else
int main(int argc, char** argv) {
return run(argc, argv);
}
#endif