From b469895aa8c7c04c17dcccf3605077f436ffb047 Mon Sep 17 00:00:00 2001 From: joffrey-b Date: Mon, 15 Jun 2026 22:25:44 +0200 Subject: [PATCH] Fix path parsing when trailing backslash precedes closing quote on Windows --- .github/workflows/build.yml | 2 +- src/easymode.cpp | 10 ++++++++++ src/scan.cpp | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 885feec..b3ba5f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -33,7 +33,7 @@ env: jobs: build_windows: name: Windows - runs-on: windows-2025 + runs-on: windows-2022 strategy: fail-fast: false env: diff --git a/src/easymode.cpp b/src/easymode.cpp index 845c80e..87109ad 100644 --- a/src/easymode.cpp +++ b/src/easymode.cpp @@ -493,7 +493,17 @@ void easy_mode(int argc, char *argv[]) quit(EXIT_FAILURE); } +#ifdef _WIN32 + // Windows CommandLineToArgvW treats \" as a literal " rather than closing + // the argument, so a path typed as "C:\foo\bar\" arrives with a trailing " + // instead of \. Strip it so filesystem operations work correctly. + std::string path_arg = argv[optind]; + if (!path_arg.empty() && path_arg.back() == '"') + path_arg.pop_back(); + scan_easy(path_arg, preset ? preset : std::filesystem::path(), threads); +#else scan_easy(argv[optind], preset ? preset : std::filesystem::path(), threads); +#endif } static bool convert_bool(const char *value, bool &setting) diff --git a/src/scan.cpp b/src/scan.cpp index e37e6de..decd62b 100644 --- a/src/scan.cpp +++ b/src/scan.cpp @@ -133,7 +133,17 @@ ScanJob* ScanJob::factory(char **files, size_t nb_files, const Config &config) std::vector tracks; std::unordered_set types; for (size_t i = 0; i < nb_files; i++) { +#ifdef _WIN32 + // Windows CommandLineToArgvW treats \" as a literal " rather than closing + // the argument, so a path typed as "C:\foo\bar\" arrives with a trailing " + // instead of \. Strip it so filesystem operations work correctly. + std::string file_str = files[i]; + if (!file_str.empty() && file_str.back() == '"') + file_str.pop_back(); + path = file_str; +#else path = files[i]; +#endif if (!std::filesystem::exists(path)) { output_error("File '{}' does not exist", path.string()); return nullptr;