Skip to content

Commit 7d07f70

Browse files
committed
rollup merge of #23383: alexcrichton/fs-create-dir-all
Conflicts: src/libstd/fs/mod.rs
2 parents c608084 + 9c906da commit 7d07f70

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/libstd/fs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ pub fn create_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
572572
#[stable(feature = "rust1", since = "1.0.0")]
573573
pub fn create_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
574574
let path = path.as_ref();
575-
if path.is_dir() { return Ok(()) }
575+
if path == Path::new("") || path.is_dir() { return Ok(()) }
576576
if let Some(p) = path.parent() { try!(create_dir_all(p)) }
577577
create_dir(path)
578578
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::env;
12+
use std::fs::{self, TempDir};
13+
14+
fn main() {
15+
let td = TempDir::new("create-dir-all-bare").unwrap();
16+
env::set_current_dir(td.path()).unwrap();
17+
fs::create_dir_all("create-dir-all-bare").unwrap();
18+
}

0 commit comments

Comments
 (0)