Rename the file permission statics in std::io to be uppercase
For example, this renames `GroupRWX` to `GROUP_RWX`, and deprecates the old name. Code using these statics should be updated accordingly.
This commit is contained in:
parent
5660db2508
commit
e3ca987f74
|
@ -1196,7 +1196,7 @@ fn compose_and_run_compiler(
|
|||
|
||||
fn ensure_dir(path: &Path) {
|
||||
if path.is_dir() { return; }
|
||||
fs::mkdir(path, io::UserRWX).unwrap();
|
||||
fs::mkdir(path, io::USER_RWX).unwrap();
|
||||
}
|
||||
|
||||
fn compose_and_run(config: &Config, testfile: &Path,
|
||||
|
|
|
@ -466,7 +466,7 @@ pub fn invalid_output_for_target(sess: &Session,
|
|||
fn is_writeable(p: &Path) -> bool {
|
||||
match p.stat() {
|
||||
Err(..) => true,
|
||||
Ok(m) => m.perm & io::UserWrite == io::UserWrite
|
||||
Ok(m) => m.perm & io::USER_WRITE == io::USER_WRITE
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1322,7 +1322,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
|
|||
// Fix up permissions of the copy, as fs::copy() preserves
|
||||
// permissions, but the original file may have been installed
|
||||
// by a package manager and may be read-only.
|
||||
match fs::chmod(&dst, io::UserRead | io::UserWrite) {
|
||||
match fs::chmod(&dst, io::USER_READ | io::USER_WRITE) {
|
||||
Ok(..) => {}
|
||||
Err(e) => {
|
||||
sess.err(format!("failed to chmod {} when preparing \
|
||||
|
|
|
@ -1467,7 +1467,7 @@ pub fn process_crate(sess: &Session,
|
|||
},
|
||||
};
|
||||
|
||||
match fs::mkdir_recursive(&root_path, io::UserRWX) {
|
||||
match fs::mkdir_recursive(&root_path, io::USER_RWX) {
|
||||
Err(e) => sess.err(format!("Could not create directory {}: {}",
|
||||
root_path.display(), e).as_slice()),
|
||||
_ => (),
|
||||
|
|
|
@ -68,7 +68,7 @@ mod test {
|
|||
let linkdir = tmpdir.join("test3");
|
||||
|
||||
File::create(&file).unwrap();
|
||||
mkdir(&dir, io::UserRWX).unwrap();
|
||||
mkdir(&dir, io::USER_RWX).unwrap();
|
||||
symlink(&file, &link).unwrap();
|
||||
symlink(&dir, &linkdir).unwrap();
|
||||
|
||||
|
@ -91,8 +91,8 @@ mod test {
|
|||
let e = d.join("e");
|
||||
let f = a.join("f");
|
||||
|
||||
mkdir_recursive(&b, io::UserRWX).unwrap();
|
||||
mkdir_recursive(&d, io::UserRWX).unwrap();
|
||||
mkdir_recursive(&b, io::USER_RWX).unwrap();
|
||||
mkdir_recursive(&d, io::USER_RWX).unwrap();
|
||||
File::create(&f).unwrap();
|
||||
symlink(&Path::new("../d/e"), &c).unwrap();
|
||||
symlink(&Path::new("../f"), &e).unwrap();
|
||||
|
|
|
@ -618,7 +618,7 @@ fn write(dst: Path, contents: &[u8]) -> io::IoResult<()> {
|
|||
/// skipping if the directory already exists.
|
||||
fn mkdir(path: &Path) -> io::IoResult<()> {
|
||||
if !path.exists() {
|
||||
fs::mkdir(path, io::UserRWX)
|
||||
fs::mkdir(path, io::USER_RWX)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -295,9 +295,9 @@ pub fn unlink(path: &Path) -> IoResult<()> {
|
|||
Ok(stat) => stat,
|
||||
Err(..) => return Err(e),
|
||||
};
|
||||
if stat.perm.intersects(io::UserWrite) { return Err(e) }
|
||||
if stat.perm.intersects(io::USER_WRITE) { return Err(e) }
|
||||
|
||||
match chmod(path, stat.perm | io::UserWrite) {
|
||||
match chmod(path, stat.perm | io::USER_WRITE) {
|
||||
Ok(()) => do_unlink(path),
|
||||
Err(..) => {
|
||||
// Try to put it back as we found it
|
||||
|
@ -501,10 +501,10 @@ pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
|
|||
/// use std::io;
|
||||
/// use std::io::fs;
|
||||
///
|
||||
/// fs::chmod(&Path::new("file.txt"), io::UserFile);
|
||||
/// fs::chmod(&Path::new("file.txt"), io::UserRead | io::UserWrite);
|
||||
/// fs::chmod(&Path::new("dir"), io::UserDir);
|
||||
/// fs::chmod(&Path::new("file.exe"), io::UserExec);
|
||||
/// fs::chmod(&Path::new("file.txt"), io::USER_FILE);
|
||||
/// fs::chmod(&Path::new("file.txt"), io::USER_READ | io::USER_WRITE);
|
||||
/// fs::chmod(&Path::new("dir"), io::USER_DIR);
|
||||
/// fs::chmod(&Path::new("file.exe"), io::USER_EXEC);
|
||||
/// ```
|
||||
///
|
||||
/// # Error
|
||||
|
@ -578,7 +578,7 @@ pub fn readlink(path: &Path) -> IoResult<Path> {
|
|||
/// use std::io::fs;
|
||||
///
|
||||
/// let p = Path::new("/some/dir");
|
||||
/// fs::mkdir(&p, io::UserRWX);
|
||||
/// fs::mkdir(&p, io::USER_RWX);
|
||||
/// ```
|
||||
///
|
||||
/// # Error
|
||||
|
@ -996,7 +996,7 @@ mod test {
|
|||
use os;
|
||||
use rand;
|
||||
let ret = os::tmpdir().join(format!("rust-{}", rand::random::<u32>()));
|
||||
check!(io::fs::mkdir(&ret, io::UserRWX));
|
||||
check!(io::fs::mkdir(&ret, io::USER_RWX));
|
||||
TempDir(ret)
|
||||
}
|
||||
|
||||
|
@ -1180,7 +1180,7 @@ mod test {
|
|||
fn file_test_stat_is_correct_on_is_dir() {
|
||||
let tmpdir = tmpdir();
|
||||
let filename = &tmpdir.join("file_stat_correct_on_is_dir");
|
||||
check!(mkdir(filename, io::UserRWX));
|
||||
check!(mkdir(filename, io::USER_RWX));
|
||||
let stat_res_fn = check!(stat(filename));
|
||||
assert!(stat_res_fn.kind == io::TypeDirectory);
|
||||
let stat_res_meth = check!(filename.stat());
|
||||
|
@ -1192,7 +1192,7 @@ mod test {
|
|||
fn file_test_fileinfo_false_when_checking_is_file_on_a_directory() {
|
||||
let tmpdir = tmpdir();
|
||||
let dir = &tmpdir.join("fileinfo_false_on_dir");
|
||||
check!(mkdir(dir, io::UserRWX));
|
||||
check!(mkdir(dir, io::USER_RWX));
|
||||
assert!(dir.is_file() == false);
|
||||
check!(rmdir(dir));
|
||||
}
|
||||
|
@ -1212,7 +1212,7 @@ mod test {
|
|||
let tmpdir = tmpdir();
|
||||
let dir = &tmpdir.join("before_and_after_dir");
|
||||
assert!(!dir.exists());
|
||||
check!(mkdir(dir, io::UserRWX));
|
||||
check!(mkdir(dir, io::USER_RWX));
|
||||
assert!(dir.exists());
|
||||
assert!(dir.is_dir());
|
||||
check!(rmdir(dir));
|
||||
|
@ -1224,7 +1224,7 @@ mod test {
|
|||
use str;
|
||||
let tmpdir = tmpdir();
|
||||
let dir = &tmpdir.join("di_readdir");
|
||||
check!(mkdir(dir, io::UserRWX));
|
||||
check!(mkdir(dir, io::USER_RWX));
|
||||
let prefix = "foo";
|
||||
for n in range(0i,3) {
|
||||
let f = dir.join(format!("{}.txt", n));
|
||||
|
@ -1255,14 +1255,14 @@ mod test {
|
|||
fn file_test_walk_dir() {
|
||||
let tmpdir = tmpdir();
|
||||
let dir = &tmpdir.join("walk_dir");
|
||||
check!(mkdir(dir, io::UserRWX));
|
||||
check!(mkdir(dir, io::USER_RWX));
|
||||
|
||||
let dir1 = &dir.join("01/02/03");
|
||||
check!(mkdir_recursive(dir1, io::UserRWX));
|
||||
check!(mkdir_recursive(dir1, io::USER_RWX));
|
||||
check!(File::create(&dir1.join("04")));
|
||||
|
||||
let dir2 = &dir.join("11/12/13");
|
||||
check!(mkdir_recursive(dir2, io::UserRWX));
|
||||
check!(mkdir_recursive(dir2, io::USER_RWX));
|
||||
check!(File::create(&dir2.join("14")));
|
||||
|
||||
let mut files = check!(walk_dir(dir));
|
||||
|
@ -1282,7 +1282,7 @@ mod test {
|
|||
fn recursive_mkdir() {
|
||||
let tmpdir = tmpdir();
|
||||
let dir = tmpdir.join("d1/d2");
|
||||
check!(mkdir_recursive(&dir, io::UserRWX));
|
||||
check!(mkdir_recursive(&dir, io::USER_RWX));
|
||||
assert!(dir.is_dir())
|
||||
}
|
||||
|
||||
|
@ -1292,10 +1292,10 @@ mod test {
|
|||
let dir = tmpdir.join("d1");
|
||||
let file = dir.join("f1");
|
||||
|
||||
check!(mkdir_recursive(&dir, io::UserRWX));
|
||||
check!(mkdir_recursive(&dir, io::USER_RWX));
|
||||
check!(File::create(&file));
|
||||
|
||||
let result = mkdir_recursive(&file, io::UserRWX);
|
||||
let result = mkdir_recursive(&file, io::USER_RWX);
|
||||
|
||||
error!(result, "couldn't recursively mkdir");
|
||||
error!(result, "couldn't create directory");
|
||||
|
@ -1305,7 +1305,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn recursive_mkdir_slash() {
|
||||
check!(mkdir_recursive(&Path::new("/"), io::UserRWX));
|
||||
check!(mkdir_recursive(&Path::new("/"), io::USER_RWX));
|
||||
}
|
||||
|
||||
// FIXME(#12795) depends on lstat to work on windows
|
||||
|
@ -1318,8 +1318,8 @@ mod test {
|
|||
let dtt = dt.join("t");
|
||||
let d2 = tmpdir.join("d2");
|
||||
let canary = d2.join("do_not_delete");
|
||||
check!(mkdir_recursive(&dtt, io::UserRWX));
|
||||
check!(mkdir_recursive(&d2, io::UserRWX));
|
||||
check!(mkdir_recursive(&dtt, io::USER_RWX));
|
||||
check!(mkdir_recursive(&d2, io::USER_RWX));
|
||||
check!(File::create(&canary).write(b"foo"));
|
||||
check!(symlink(&d2, &dt.join("d2")));
|
||||
check!(rmdir_recursive(&d1));
|
||||
|
@ -1337,7 +1337,7 @@ mod test {
|
|||
|
||||
let mut dirpath = tmpdir.path().clone();
|
||||
dirpath.push(format!("test-가一ー你好"));
|
||||
check!(mkdir(&dirpath, io::UserRWX));
|
||||
check!(mkdir(&dirpath, io::USER_RWX));
|
||||
assert!(dirpath.is_dir());
|
||||
|
||||
let mut filepath = dirpath;
|
||||
|
@ -1355,7 +1355,7 @@ mod test {
|
|||
let tmpdir = tmpdir();
|
||||
let unicode = tmpdir.path();
|
||||
let unicode = unicode.join(format!("test-각丁ー再见"));
|
||||
check!(mkdir(&unicode, io::UserRWX));
|
||||
check!(mkdir(&unicode, io::USER_RWX));
|
||||
assert!(unicode.exists());
|
||||
assert!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists());
|
||||
}
|
||||
|
@ -1436,12 +1436,12 @@ mod test {
|
|||
let out = tmpdir.join("out.txt");
|
||||
|
||||
check!(File::create(&input));
|
||||
check!(chmod(&input, io::UserRead));
|
||||
check!(chmod(&input, io::USER_READ));
|
||||
check!(copy(&input, &out));
|
||||
assert!(!check!(out.stat()).perm.intersects(io::UserWrite));
|
||||
assert!(!check!(out.stat()).perm.intersects(io::USER_WRITE));
|
||||
|
||||
check!(chmod(&input, io::UserFile));
|
||||
check!(chmod(&out, io::UserFile));
|
||||
check!(chmod(&input, io::USER_FILE));
|
||||
check!(chmod(&out, io::USER_FILE));
|
||||
}
|
||||
|
||||
#[cfg(not(windows))] // FIXME(#10264) operation not permitted?
|
||||
|
@ -1517,16 +1517,16 @@ mod test {
|
|||
let file = tmpdir.join("in.txt");
|
||||
|
||||
check!(File::create(&file));
|
||||
assert!(check!(stat(&file)).perm.contains(io::UserWrite));
|
||||
check!(chmod(&file, io::UserRead));
|
||||
assert!(!check!(stat(&file)).perm.contains(io::UserWrite));
|
||||
assert!(check!(stat(&file)).perm.contains(io::USER_WRITE));
|
||||
check!(chmod(&file, io::USER_READ));
|
||||
assert!(!check!(stat(&file)).perm.contains(io::USER_WRITE));
|
||||
|
||||
match chmod(&tmpdir.join("foo"), io::UserRWX) {
|
||||
match chmod(&tmpdir.join("foo"), io::USER_RWX) {
|
||||
Ok(..) => fail!("wanted a failure"),
|
||||
Err(..) => {}
|
||||
}
|
||||
|
||||
check!(chmod(&file, io::UserFile));
|
||||
check!(chmod(&file, io::USER_FILE));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1677,7 +1677,7 @@ mod test {
|
|||
let tmpdir = tmpdir();
|
||||
let path = tmpdir.join("file");
|
||||
check!(File::create(&path));
|
||||
check!(chmod(&path, io::UserRead));
|
||||
check!(chmod(&path, io::USER_READ));
|
||||
check!(unlink(&path));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1803,35 +1803,93 @@ bitflags! {
|
|||
#[doc = "A set of permissions for a file or directory is represented"]
|
||||
#[doc = "by a set of flags which are or'd together."]
|
||||
flags FilePermission: u32 {
|
||||
static UserRead = 0o400,
|
||||
static UserWrite = 0o200,
|
||||
static UserExecute = 0o100,
|
||||
static GroupRead = 0o040,
|
||||
static GroupWrite = 0o020,
|
||||
static GroupExecute = 0o010,
|
||||
static OtherRead = 0o004,
|
||||
static OtherWrite = 0o002,
|
||||
static OtherExecute = 0o001,
|
||||
static USER_READ = 0o400,
|
||||
static USER_WRITE = 0o200,
|
||||
static USER_EXECUTE = 0o100,
|
||||
static GROUP_READ = 0o040,
|
||||
static GROUP_WRITE = 0o020,
|
||||
static GROUP_EXECUTE = 0o010,
|
||||
static OTHER_READ = 0o004,
|
||||
static OTHER_WRITE = 0o002,
|
||||
static OTHER_EXECUTE = 0o001,
|
||||
|
||||
static UserRWX = UserRead.bits | UserWrite.bits | UserExecute.bits,
|
||||
static GroupRWX = GroupRead.bits | GroupWrite.bits | GroupExecute.bits,
|
||||
static OtherRWX = OtherRead.bits | OtherWrite.bits | OtherExecute.bits,
|
||||
static USER_RWX = USER_READ.bits | USER_WRITE.bits | USER_EXECUTE.bits,
|
||||
static GROUP_RWX = GROUP_READ.bits | GROUP_WRITE.bits | GROUP_EXECUTE.bits,
|
||||
static OTHER_RWX = OTHER_READ.bits | OTHER_WRITE.bits | OTHER_EXECUTE.bits,
|
||||
|
||||
#[doc = "Permissions for user owned files, equivalent to 0644 on"]
|
||||
#[doc = "unix-like systems."]
|
||||
static UserFile = UserRead.bits | UserWrite.bits | GroupRead.bits | OtherRead.bits,
|
||||
static USER_FILE = USER_READ.bits | USER_WRITE.bits | GROUP_READ.bits | OTHER_READ.bits,
|
||||
|
||||
#[doc = "Permissions for user owned directories, equivalent to 0755 on"]
|
||||
#[doc = "unix-like systems."]
|
||||
static UserDir = UserRWX.bits | GroupRead.bits | GroupExecute.bits |
|
||||
OtherRead.bits | OtherExecute.bits,
|
||||
static USER_DIR = USER_RWX.bits | GROUP_READ.bits | GROUP_EXECUTE.bits |
|
||||
OTHER_READ.bits | OTHER_EXECUTE.bits,
|
||||
|
||||
#[doc = "Permissions for user owned executables, equivalent to 0755"]
|
||||
#[doc = "on unix-like systems."]
|
||||
static UserExec = UserDir.bits,
|
||||
static USER_EXEC = USER_DIR.bits,
|
||||
|
||||
#[doc = "All possible permissions enabled."]
|
||||
static AllPermissions = UserRWX.bits | GroupRWX.bits | OtherRWX.bits,
|
||||
static ALL_PERMISSIONS = USER_RWX.bits | GROUP_RWX.bits | OTHER_RWX.bits,
|
||||
|
||||
// Deprecated names
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use USER_READ instead"]
|
||||
static UserRead = USER_READ.bits,
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use USER_WRITE instead"]
|
||||
static UserWrite = USER_WRITE.bits,
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use USER_EXECUTE instead"]
|
||||
static UserExecute = USER_EXECUTE.bits,
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use GROUP_READ instead"]
|
||||
static GroupRead = GROUP_READ.bits,
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use GROUP_WRITE instead"]
|
||||
static GroupWrite = GROUP_WRITE.bits,
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use GROUP_EXECUTE instead"]
|
||||
static GroupExecute = GROUP_EXECUTE.bits,
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use OTHER_READ instead"]
|
||||
static OtherRead = OTHER_READ.bits,
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use OTHER_WRITE instead"]
|
||||
static OtherWrite = OTHER_WRITE.bits,
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use OTHER_EXECUTE instead"]
|
||||
static OtherExecute = OTHER_EXECUTE.bits,
|
||||
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use USER_RWX instead"]
|
||||
static UserRWX = USER_RWX.bits,
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use GROUP_RWX instead"]
|
||||
static GroupRWX = GROUP_RWX.bits,
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use OTHER_RWX instead"]
|
||||
static OtherRWX = OTHER_RWX.bits,
|
||||
|
||||
#[doc = "Deprecated: use `USER_FILE` instead."]
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use USER_FILE instead"]
|
||||
static UserFile = USER_FILE.bits,
|
||||
|
||||
#[doc = "Deprecated: use `USER_DIR` instead."]
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use USER_DIR instead"]
|
||||
static UserDir = USER_DIR.bits,
|
||||
#[doc = "Deprecated: use `USER_EXEC` instead."]
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use USER_EXEC instead"]
|
||||
static UserExec = USER_EXEC.bits,
|
||||
|
||||
#[doc = "Deprecated: use `ALL_PERMISSIONS` instead"]
|
||||
#[allow(non_uppercase_statics)]
|
||||
#[deprecated = "use ALL_PERMISSIONS instead"]
|
||||
static AllPermissions = ALL_PERMISSIONS.bits,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1954,13 +2012,13 @@ mod tests {
|
|||
fn test_show() {
|
||||
use super::*;
|
||||
|
||||
assert_eq!(format!("{}", UserRead), "0400".to_string());
|
||||
assert_eq!(format!("{}", UserFile), "0644".to_string());
|
||||
assert_eq!(format!("{}", UserExec), "0755".to_string());
|
||||
assert_eq!(format!("{}", UserRWX), "0700".to_string());
|
||||
assert_eq!(format!("{}", GroupRWX), "0070".to_string());
|
||||
assert_eq!(format!("{}", OtherRWX), "0007".to_string());
|
||||
assert_eq!(format!("{}", AllPermissions), "0777".to_string());
|
||||
assert_eq!(format!("{}", UserRead | UserWrite | OtherWrite), "0602".to_string());
|
||||
assert_eq!(format!("{}", USER_READ), "0400".to_string());
|
||||
assert_eq!(format!("{}", USER_FILE), "0644".to_string());
|
||||
assert_eq!(format!("{}", USER_EXEC), "0755".to_string());
|
||||
assert_eq!(format!("{}", USER_RWX), "0700".to_string());
|
||||
assert_eq!(format!("{}", GROUP_RWX), "0070".to_string());
|
||||
assert_eq!(format!("{}", OTHER_RWX), "0007".to_string());
|
||||
assert_eq!(format!("{}", ALL_PERMISSIONS), "0777".to_string());
|
||||
assert_eq!(format!("{}", USER_READ | USER_WRITE | OTHER_WRITE), "0602".to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ impl TempDir {
|
|||
unsafe { CNT.fetch_add(1, atomic::SeqCst) },
|
||||
suffix);
|
||||
let p = tmpdir.join(filename);
|
||||
match fs::mkdir(&p, io::UserRWX) {
|
||||
match fs::mkdir(&p, io::USER_RWX) {
|
||||
Err(error) => {
|
||||
if attempts >= 1000 {
|
||||
return Err(error)
|
||||
|
|
|
@ -51,7 +51,7 @@ fn main() {
|
|||
let child_path = cwd.join(child_filename.clone());
|
||||
|
||||
// make a separate directory for the child
|
||||
drop(fs::mkdir(&cwd, io::UserRWX).is_ok());
|
||||
drop(fs::mkdir(&cwd, io::USER_RWX).is_ok());
|
||||
assert!(fs::copy(&my_path, &child_path).is_ok());
|
||||
|
||||
// run child
|
||||
|
|
|
@ -26,7 +26,7 @@ fn rename_directory() {
|
|||
let tmpdir = TempDir::new("rename_directory").ok().expect("rename_directory failed");
|
||||
let tmpdir = tmpdir.path();
|
||||
let old_path = tmpdir.join_many(["foo", "bar", "baz"]);
|
||||
fs::mkdir_recursive(&old_path, io::UserRWX);
|
||||
fs::mkdir_recursive(&old_path, io::USER_RWX);
|
||||
let test_file = &old_path.join("temp.txt");
|
||||
|
||||
/* Write the temp input file */
|
||||
|
@ -47,7 +47,7 @@ fn rename_directory() {
|
|||
assert_eq!(libc::fclose(ostream), (0u as libc::c_int));
|
||||
|
||||
let new_path = tmpdir.join_many(["quux", "blat"]);
|
||||
fs::mkdir_recursive(&new_path, io::UserRWX);
|
||||
fs::mkdir_recursive(&new_path, io::USER_RWX);
|
||||
fs::rename(&old_path, &new_path.join("newdir"));
|
||||
assert!(new_path.join("newdir").is_dir());
|
||||
assert!(new_path.join_many(["newdir", "temp.txt"]).exists());
|
||||
|
|
|
@ -128,17 +128,17 @@ fn recursive_mkdir_rel() {
|
|||
let cwd = os::getcwd();
|
||||
println!("recursive_mkdir_rel: Making: {} in cwd {} [{:?}]", path.display(),
|
||||
cwd.display(), path.exists());
|
||||
fs::mkdir_recursive(&path, io::UserRWX);
|
||||
fs::mkdir_recursive(&path, io::USER_RWX);
|
||||
assert!(path.is_dir());
|
||||
fs::mkdir_recursive(&path, io::UserRWX);
|
||||
fs::mkdir_recursive(&path, io::USER_RWX);
|
||||
assert!(path.is_dir());
|
||||
}
|
||||
|
||||
fn recursive_mkdir_dot() {
|
||||
let dot = Path::new(".");
|
||||
fs::mkdir_recursive(&dot, io::UserRWX);
|
||||
fs::mkdir_recursive(&dot, io::USER_RWX);
|
||||
let dotdot = Path::new("..");
|
||||
fs::mkdir_recursive(&dotdot, io::UserRWX);
|
||||
fs::mkdir_recursive(&dotdot, io::USER_RWX);
|
||||
}
|
||||
|
||||
fn recursive_mkdir_rel_2() {
|
||||
|
@ -146,20 +146,20 @@ fn recursive_mkdir_rel_2() {
|
|||
let cwd = os::getcwd();
|
||||
println!("recursive_mkdir_rel_2: Making: {} in cwd {} [{:?}]", path.display(),
|
||||
cwd.display(), path.exists());
|
||||
fs::mkdir_recursive(&path, io::UserRWX);
|
||||
fs::mkdir_recursive(&path, io::USER_RWX);
|
||||
assert!(path.is_dir());
|
||||
assert!(path.dir_path().is_dir());
|
||||
let path2 = Path::new("quux/blat");
|
||||
println!("recursive_mkdir_rel_2: Making: {} in cwd {}", path2.display(),
|
||||
cwd.display());
|
||||
fs::mkdir_recursive(&path2, io::UserRWX);
|
||||
fs::mkdir_recursive(&path2, io::USER_RWX);
|
||||
assert!(path2.is_dir());
|
||||
assert!(path2.dir_path().is_dir());
|
||||
}
|
||||
|
||||
// Ideally this would be in core, but needs TempFile
|
||||
pub fn test_rmdir_recursive_ok() {
|
||||
let rwx = io::UserRWX;
|
||||
let rwx = io::USER_RWX;
|
||||
|
||||
let tmpdir = TempDir::new("test").ok().expect("test_rmdir_recursive_ok: \
|
||||
couldn't create temp dir");
|
||||
|
|
Loading…
Reference in New Issue