about summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-11-22 15:45:12 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-11-29 10:55:13 -0800
commitc54427ddfbbab41a39d14f2b1dc4f080cbc2d41b (patch)
tree7b4e7af9dfe4342f3fd474f1010d4839281edd87 /src/libstd/io
parent6c672ee094a1a8e72c100100f43c73a9741f08a7 (diff)
downloadrust-c54427ddfbbab41a39d14f2b1dc4f080cbc2d41b.tar.gz
rust-c54427ddfbbab41a39d14f2b1dc4f080cbc2d41b.zip
libstd: Change `Path::new` to `Path::init`.
Diffstat (limited to 'src/libstd/io')
-rw-r--r--src/libstd/io/fs.rs48
-rw-r--r--src/libstd/io/mod.rs2
-rw-r--r--src/libstd/io/native/file.rs17
-rw-r--r--src/libstd/io/native/process.rs2
4 files changed, 35 insertions, 34 deletions
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs
index a4be74d1d7f..ee7d851679d 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::new("foo.txt");
+    let path = Path::init("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::new("bar.txt"));
+    fs::symlink(&path, &Path::init("bar.txt"));
     fs::unlink(&path);
 
 */
@@ -95,7 +95,7 @@ impl File {
     ///
     ///     use std::io::{File, io_error, Open, ReadWrite};
     ///
-    ///     let p = Path::new("/some/file/path.txt");
+    ///     let p = Path::init("/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::new("foo.txt")).read_to_end();
+    ///     let contents = File::open(&Path::init("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::new("foo.txt"));
+    ///     let mut f = File::create(&Path::init("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::new("/some/file/path.txt");
+///     let p = Path::init("/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::new("/some/file/path.txt");
+///     let p = Path::init("/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::new(""),
+        path: Path::init(""),
         size: 0,
         kind: io::TypeFile,
         perm: 0,
@@ -317,7 +317,7 @@ pub fn lstat(path: &Path) -> FileStat {
 ///
 ///     use std::io::fs;
 ///
-///     fs::rename(&Path::new("foo"), &Path::new("bar"));
+///     fs::rename(&Path::init("foo"), &Path::init("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::new("foo.txt"), &Path::new("bar.txt"));
+///     fs::copy(&Path::init("foo.txt"), &Path::init("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::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::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);
 ///
 /// # Errors
 ///
@@ -448,7 +448,7 @@ pub fn readlink(path: &Path) -> Option<Path> {
 ///     use std::libc::S_IRWXU;
 ///     use std::io::fs;
 ///
-///     let p = Path::new("/some/dir");
+///     let p = Path::init("/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::new("/some/dir");
+///     let p = Path::init("/some/dir");
 ///     fs::rmdir(&p);
 ///     // good riddance, you mean ol' directory
 ///
@@ -990,12 +990,12 @@ mod test {
     })
 
     test!(fn recursive_mkdir_slash() {
-        mkdir_recursive(&Path::new("/"), io::UserRWX);
+        mkdir_recursive(&Path::init("/"), io::UserRWX);
     })
 
     test!(fn unicode_path_is_dir() {
-        assert!(Path::new(".").is_dir());
-        assert!(!Path::new("test/stdtest/fs.rs").is_dir());
+        assert!(Path::init(".").is_dir());
+        assert!(!Path::init("test/stdtest/fs.rs").is_dir());
 
         let tmpdir = tmpdir();
 
@@ -1012,20 +1012,20 @@ mod test {
     })
 
     test!(fn unicode_path_exists() {
-        assert!(Path::new(".").exists());
-        assert!(!Path::new("test/nonexistent-bogus-path").exists());
+        assert!(Path::init(".").exists());
+        assert!(!Path::init("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::new("test/unicode-bogus-path-각丁ー再见").exists());
+        assert!(!Path::init("test/unicode-bogus-path-각丁ー再见").exists());
     })
 
     test!(fn copy_file_does_not_exist() {
-        let from = Path::new("test/nonexistent-bogus-path");
-        let to = Path::new("test/other-bogus-path");
+        let from = Path::init("test/nonexistent-bogus-path");
+        let to = Path::init("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 8b680020fd9..c00233dda55 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::new("foo.txt"))
+    ///     let reader = File::open(&Path::init("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 218040b72d6..c3c7540df86 100644
--- a/src/libstd/io/native/file.rs
+++ b/src/libstd/io/native/file.rs
@@ -278,6 +278,7 @@ 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 {
@@ -480,7 +481,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::new(root);
+        let root = Path::init(root);
 
         dirs.move_iter().filter(|path| {
             path.as_vec() != bytes!(".") && path.as_vec() != bytes!("..")
@@ -505,7 +506,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::new(cstr));
+                    paths.push(Path::init(cstr));
                     entry_ptr = readdir(dir_ptr);
                 }
                 closedir(dir_ptr);
@@ -536,7 +537,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::new(p);
+            let p = Path::init(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);
@@ -553,7 +554,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::new(fp_str));
+                            paths.push(Path::init(fp_str));
                         }
                         more_files = FindNextFileW(find_handle, wfd_ptr as HANDLE);
                     }
@@ -683,7 +684,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> {
             }
         });
         let ret = match ret {
-            Some(s) => Ok(Path::new(s)),
+            Some(s) => Ok(Path::init(s)),
             None => Err(super::last_error()),
         };
         unsafe { libc::CloseHandle(handle) };
@@ -707,7 +708,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> {
             n => {
                 assert!(n > 0);
                 unsafe { vec::raw::set_len(&mut buf, n as uint); }
-                Ok(Path::new(buf))
+                Ok(Path::init(buf))
             }
         }
     }
@@ -770,7 +771,7 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat {
     };
 
     io::FileStat {
-        path: Path::new(path),
+        path: Path::init(path),
         size: stat.st_size as u64,
         kind: kind,
         perm: (stat.st_mode) as io::FilePermission & io::AllPermissions,
@@ -819,7 +820,7 @@ fn mkstat(stat: &libc::stat, path: &CString) -> io::FileStat {
     fn gen(_stat: &libc::stat) -> u64 { 0 }
 
     io::FileStat {
-        path: Path::new(path),
+        path: Path::init(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 1b614852737..3113fbeb095 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::new(a));
+        let cwd = config.cwd.map(|a| Path::init(a));
         let res = spawn_process_os(config.program, config.args, env,
                                    cwd.as_ref(), in_fd, out_fd, err_fd);