Skip to content

Fix path parsing when trailing backslash precedes closing quote on Windows#189

Open
joffrey-b wants to merge 1 commit into
complexlogic:masterfrom
joffrey-b:fix-windows-trailing-backslash-path
Open

Fix path parsing when trailing backslash precedes closing quote on Windows#189
joffrey-b wants to merge 1 commit into
complexlogic:masterfrom
joffrey-b:fix-windows-trailing-backslash-path

Conversation

@joffrey-b

Copy link
Copy Markdown

Summary

On Windows, passing a quoted path with a trailing backslash (e.g. "C:\Music\My Album\") causes rsgain to report a misleading "does not exist" error, with a stray " visible at the end of the path in the error message. This affects both easy mode and custom mode.

Closes #187

Root cause

Windows' CommandLineToArgvW treats \" as an escaped literal " rather than the closing delimiter of a quoted argument. As a result, a path like "C:\Music\My Album\" is parsed by the C runtime as C:\Music\My Album" — the trailing backslash is consumed as an escape character, and the quote becomes part of the string.

This is a common friction point because PowerShell tab-completion for paths with spaces automatically appends a trailing \, making this the default form users encounter.

Fix

Before constructing a std::filesystem::path from a command-line path argument on Windows, strip a trailing " character if present.

Changes

  • src/easymode.cpp — strip trailing " from the directory argument before passing to scan_easy()
  • src/scan.cpp — strip trailing " from each file path argument before assigning to the filesystem path

Testing

Tested on Windows 11 with PowerShell. The following previously failing invocations now work correctly:

rsgain easy "C:\Music\My Album\"
rsgain easy 'C:\Music\My Album\'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: path with trailing backslash causes "does not exist" error

1 participant