Skip to content

Fix set_directory on Windows for \\?\UNC\ paths and / separators - #372

Open
Jetttyy777 wants to merge 1 commit into
PolyMeilex:masterfrom
Jetttyy777:fix/windows-set-directory-unc-and-slashes
Open

Jetttyy777 wants to merge 1 commit into
PolyMeilex:masterfrom
Jetttyy777:fix/windows-set-directory-unc-and-slashes

Conversation

@Jetttyy777

Copy link
Copy Markdown

Fixes #307

on windows, set_directory was getting silently ignored in two cases:

  • network share paths: canonicalize returns \\?\UNC\server\share, and stripping the \\?\ leaves UNC\server\share, which isn't a valid path
  • any path with a / in it, since the dialog doesn't accept those

a small helper now turns \\?\UNC\server\share into \\server\share, strips \\?\ from normal paths, and swaps / for \

added 4 tests and a changelog entry. heads up, i only tested this with the unit tests, not against a real network share

The shell can't parse paths with the `\?\` prefix or `/` separators,
and `SHCreateItemFromParsingName` fails on them, so the dialog silently
ignored the directory. Stripping only `\?\` turned the `\?\UNC\...`
paths that `std::fs::canonicalize` returns for network shares into an
invalid `UNC\...` path.

Turn `\?\UNC\server\share` into `\server\share`, strip `\?\` from
other paths, and replace `/` with `\`.

Fixes PolyMeilex#307.
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.

Cannot set starting directory to a network-mapped path on Windows

1 participant