diff options
| author | bors <bors@rust-lang.org> | 2013-12-04 23:26:19 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-12-04 23:26:19 -0800 |
| commit | b5bab85c1a41bcd7758fb8090a3cf3ba20e33b48 (patch) | |
| tree | ca9f9e55e2369c253cedd265d7273553370cfb8d /src/libstd/io | |
| parent | 10c8409c786b8ee43c00fadfa1be6ebbfc846a91 (diff) | |
| parent | b1705714d5a13e9057db364b685c7cce7cc27982 (diff) | |
| download | rust-b5bab85c1a41bcd7758fb8090a3cf3ba20e33b48.tar.gz rust-b5bab85c1a41bcd7758fb8090a3cf3ba20e33b48.zip | |
auto merge of #10796 : kballard/rust/revert-new-naming, r=alexcrichton
Rename the `*::init()` functions back to `*::new()`, since `new` is not going to become a keyword.
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/fs.rs | 48 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/native/file.rs | 17 | ||||
| -rw-r--r-- | src/libstd/io/native/process.rs | 2 |
4 files changed, 34 insertions, 35 deletions
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index f0b51a2c3e0..23bf5cdc564 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -29,7 +29,7 @@ particular bits of it, etc. use std::io::{File, fs}; - let path = Path::init("foo.txt"); + let path = Path::new("foo.txt"); // create the file, whether it exists or not let mut file = File::create(&path); @@ -40,7 +40,7 @@ particular bits of it, etc. file.read_to_end(); println!("{}", path.stat().size); - fs::symlink(&path, &Path::init("bar.txt")); + fs::symlink(&path, &Path::new("bar.txt")); fs::unlink(&path); */ @@ -95,7 +95,7 @@ impl File { /// /// use std::io::{File, io_error, Open, ReadWrite}; /// - /// let p = Path::init("/some/file/path.txt"); + /// let p = Path::new("/some/file/path.txt"); /// /// io_error::cond.trap(|_| { /// // hoo-boy... @@ -157,7 +157,7 @@ impl File { /// /// use std::io::File; /// - /// let contents = File::open(&Path::init("foo.txt")).read_to_end(); + /// let contents = File::open(&Path::new("foo.txt")).read_to_end(); pub fn open(path: &Path) -> Option<File> { File::open_mode(path, Open, Read) } @@ -172,7 +172,7 @@ impl File { /// /// use std::io::File; /// - /// let mut f = File::create(&Path::init("foo.txt")); + /// let mut f = File::create(&Path::new("foo.txt")); /// f.write(bytes!("This is a sample file")); pub fn create(path: &Path) -> Option<File> { File::open_mode(path, Truncate, Write) @@ -229,7 +229,7 @@ impl File { /// /// use std::io::fs; /// -/// let p = Path::init("/some/file/path.txt"); +/// let p = Path::new("/some/file/path.txt"); /// fs::unlink(&p); /// // if we made it here without failing, then the /// // unlink operation was successful @@ -260,7 +260,7 @@ pub fn unlink(path: &Path) { /// use std::io; /// use std::io::fs; /// -/// let p = Path::init("/some/file/path.txt"); +/// let p = Path::new("/some/file/path.txt"); /// match io::result(|| fs::stat(&p)) { /// Ok(stat) => { /* ... */ } /// Err(e) => { /* handle error */ } @@ -277,7 +277,7 @@ pub fn stat(path: &Path) -> FileStat { fn dummystat() -> FileStat { FileStat { - path: Path::init(""), + path: Path::new(""), size: 0, kind: io::TypeFile, perm: 0, @@ -317,7 +317,7 @@ pub fn lstat(path: &Path) -> FileStat { /// /// use std::io::fs; /// -/// fs::rename(&Path::init("foo"), &Path::init("bar")); +/// fs::rename(&Path::new("foo"), &Path::new("bar")); /// // Oh boy, nothing was raised! /// /// # Errors @@ -339,7 +339,7 @@ pub fn rename(from: &Path, to: &Path) { /// /// use std::io::fs; /// -/// fs::copy(&Path::init("foo.txt"), &Path::init("bar.txt")); +/// fs::copy(&Path::new("foo.txt"), &Path::new("bar.txt")); /// // Oh boy, nothing was raised! /// /// # Errors @@ -386,10 +386,10 @@ pub fn copy(from: &Path, to: &Path) { /// use std::io; /// use std::io::fs; /// -/// fs::chmod(&Path::init("file.txt"), io::UserFile); -/// fs::chmod(&Path::init("file.txt"), io::UserRead | io::UserWrite); -/// fs::chmod(&Path::init("dir"), io::UserDir); -/// fs::chmod(&Path::init("file.exe"), io::UserExec); +/// 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); /// /// # Errors /// @@ -448,7 +448,7 @@ pub fn readlink(path: &Path) -> Option<Path> { /// use std::libc::S_IRWXU; /// use std::io::fs; /// -/// let p = Path::init("/some/dir"); +/// let p = Path::new("/some/dir"); /// fs::mkdir(&p, S_IRWXU as int); /// // If we got here, our directory exists! Horray! /// @@ -467,7 +467,7 @@ pub fn mkdir(path: &Path, mode: FilePermission) { /// /// use std::io::fs; /// -/// let p = Path::init("/some/dir"); +/// let p = Path::new("/some/dir"); /// fs::rmdir(&p); /// // good riddance, you mean ol' directory /// @@ -987,12 +987,12 @@ mod test { }) test!(fn recursive_mkdir_slash() { - mkdir_recursive(&Path::init("/"), io::UserRWX); + mkdir_recursive(&Path::new("/"), io::UserRWX); }) test!(fn unicode_path_is_dir() { - assert!(Path::init(".").is_dir()); - assert!(!Path::init("test/stdtest/fs.rs").is_dir()); + assert!(Path::new(".").is_dir()); + assert!(!Path::new("test/stdtest/fs.rs").is_dir()); let tmpdir = tmpdir(); @@ -1009,20 +1009,20 @@ mod test { }) test!(fn unicode_path_exists() { - assert!(Path::init(".").exists()); - assert!(!Path::init("test/nonexistent-bogus-path").exists()); + assert!(Path::new(".").exists()); + assert!(!Path::new("test/nonexistent-bogus-path").exists()); let tmpdir = tmpdir(); let unicode = tmpdir.clone(); let unicode = unicode.join(format!("test-각丁ー再见")); mkdir(&unicode, io::UserRWX); assert!(unicode.exists()); - assert!(!Path::init("test/unicode-bogus-path-각丁ー再见").exists()); + assert!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists()); }) test!(fn copy_file_does_not_exist() { - let from = Path::init("test/nonexistent-bogus-path"); - let to = Path::init("test/other-bogus-path"); + let from = Path::new("test/nonexistent-bogus-path"); + let to = Path::new("test/other-bogus-path"); match io::result(|| copy(&from, &to)) { Ok(..) => fail!(), Err(..) => { diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 208c64f5ef4..edc6728a0c1 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -450,7 +450,7 @@ pub trait Reader { /// /// # Example /// - /// let reader = File::open(&Path::init("foo.txt")) + /// let reader = File::open(&Path::new("foo.txt")) /// while !reader.eof() { /// println(reader.read_line()); /// } diff --git a/src/libstd/io/native/file.rs b/src/libstd/io/native/file.rs index c3c7540df86..218040b72d6 100644 --- a/src/libstd/io/native/file.rs +++ b/src/libstd/io/native/file.rs @@ -278,7 +278,6 @@ impl rtio::RtioFileStream for FileDesc { self.seek(orig_pos as i64, io::SeekSet); return ret; } - #[cfg(unix)] fn truncate(&mut self, offset: i64) -> Result<(), IoError> { super::mkerr_libc(unsafe { @@ -481,7 +480,7 @@ pub fn mkdir(p: &CString, mode: io::FilePermission) -> IoResult<()> { pub fn readdir(p: &CString) -> IoResult<~[Path]> { fn prune(root: &CString, dirs: ~[Path]) -> ~[Path] { let root = unsafe { CString::new(root.with_ref(|p| p), false) }; - let root = Path::init(root); + let root = Path::new(root); dirs.move_iter().filter(|path| { path.as_vec() != bytes!(".") && path.as_vec() != bytes!("..") @@ -506,7 +505,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> { let mut entry_ptr = readdir(dir_ptr); while (entry_ptr as uint != 0) { let cstr = CString::new(rust_list_dir_val(entry_ptr), false); - paths.push(Path::init(cstr)); + paths.push(Path::new(cstr)); entry_ptr = readdir(dir_ptr); } closedir(dir_ptr); @@ -537,7 +536,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> { fn rust_list_dir_wfd_fp_buf(wfd: *libc::c_void) -> *u16; } let p = CString::new(p.with_ref(|p| p), false); - let p = Path::init(p); + let p = Path::new(p); let star = p.join("*"); as_utf16_p(star.as_str().unwrap(), |path_ptr| { let wfd_ptr = malloc_raw(rust_list_dir_wfd_size() as uint); @@ -554,7 +553,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> { let fp_vec = vec::from_buf( fp_buf, wcslen(fp_buf) as uint); let fp_str = str::from_utf16(fp_vec); - paths.push(Path::init(fp_str)); + paths.push(Path::new(fp_str)); } more_files = FindNextFileW(find_handle, wfd_ptr as HANDLE); } @@ -684,7 +683,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> { } }); let ret = match ret { - Some(s) => Ok(Path::init(s)), + Some(s) => Ok(Path::new(s)), None => Err(super::last_error()), }; unsafe { libc::CloseHandle(handle) }; @@ -708,7 +707,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> { n => { assert!(n > 0); unsafe { vec::raw::set_len(&mut buf, n as uint); } - Ok(Path::init(buf)) + Ok(Path::new(buf)) } } } @@ -771,7 +770,7 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat { }; io::FileStat { - path: Path::init(path), + path: Path::new(path), size: stat.st_size as u64, kind: kind, perm: (stat.st_mode) as io::FilePermission & io::AllPermissions, @@ -820,7 +819,7 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat { fn gen(_stat: &libc::stat) -> u64 { 0 } io::FileStat { - path: Path::init(path), + path: Path::new(path), size: stat.st_size as u64, kind: kind, perm: (stat.st_mode) as io::FilePermission & io::AllPermissions, diff --git a/src/libstd/io/native/process.rs b/src/libstd/io/native/process.rs index 3113fbeb095..1b614852737 100644 --- a/src/libstd/io/native/process.rs +++ b/src/libstd/io/native/process.rs @@ -95,7 +95,7 @@ impl Process { let (err_pipe, err_fd) = get_io(config.io, &mut ret_io, 2); let env = config.env.map(|a| a.to_owned()); - let cwd = config.cwd.map(|a| Path::init(a)); + let cwd = config.cwd.map(|a| Path::new(a)); let res = spawn_process_os(config.program, config.args, env, cwd.as_ref(), in_fd, out_fd, err_fd); |
