rust-lang / rust-lang/rust

`Dir::open_file_with` (and likely more `Dir` methods) on Windows does not support `/`

Open
#163,032 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Usually, our fs methods on Windows support the / file separator, not just \. However, for the Dir methods, that does not seem to be true -- the following fails

dir.open_file_with("subdir/bar.txt", &OpenOptions::new().create(true).write(true))

saying

The filename, directory name, or volume label syntax is incorrect. (os error 123)

I suspect this is caused by internally using NtCreateFile rather than CreateFileW.

Tracking issue: https://github.com/rust-lang/rust/issues/120426
Cc @ChrisDenton @Qelxiros

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Windows implementation of Dir methods involved in Dir::open_file_with and compare the failing "subdir/bar.txt" reproducer with the behavior of the fs methods that accept '/'. Inspect the suspected NtCreateFile path and the tracking issue #120426; done means the Dir methods accept '/' on Windows without the reported OS error.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.