Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3742,6 +3742,11 @@ impl DirBuilder {
return Ok(());
}

// For certain platforms, a path like "/tmp/foo/.", while the "/tmp" directory exists,
// the mkdir function may produce a `NotFound` error on that path instead of succeeding
// due to viewing the "foo" and "." as two separate missing components.
// See https://github.com/rust-lang/rust/issues/162243
let path = path.components().as_path();
let ancestors = path.ancestors();
let mut uncreated_dirs = 0;

Expand Down
8 changes: 8 additions & 0 deletions library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,14 @@ fn recursive_mkdir() {
assert!(dir.is_dir())
}

#[test]
fn recursive_mkdir_with_trailing_cur_dir() {
let tmpdir = tmpdir();
let dir = tmpdir.join("foo").join(".");
check!(fs::create_dir_all(&dir));
assert!(dir.is_dir())
}

#[test]
fn recursive_mkdir_failure() {
let tmpdir = tmpdir();
Expand Down
Loading