about summary refs log tree commit diff
path: root/src/libstd/io.rs
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2013-09-26 17:21:59 -0700
committerKevin Ballard <kevin@sb.org>2013-10-15 21:56:54 -0700
commit73d3d00ec437f87ac665b4e4da3bedec8ce4f9ef (patch)
tree7050b2b93e3c58d7766e9aecd7e973ea88d9210e /src/libstd/io.rs
parent6741241f4046aea4014b1a23618593fb481c8606 (diff)
downloadrust-73d3d00ec437f87ac665b4e4da3bedec8ce4f9ef.tar.gz
rust-73d3d00ec437f87ac665b4e4da3bedec8ce4f9ef.zip
path2: Replace the path module outright
Remove the old path.
Rename path2 to path.
Update all clients for the new path.

Also make some miscellaneous changes to the Path APIs to help the
adoption process.
Diffstat (limited to 'src/libstd/io.rs')
-rw-r--r--src/libstd/io.rs35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/libstd/io.rs b/src/libstd/io.rs
index 7160496f4ab..434d781805b 100644
--- a/src/libstd/io.rs
+++ b/src/libstd/io.rs
@@ -60,12 +60,11 @@ use num;
 use ops::Drop;
 use option::{Some, None};
 use os;
-use path::Path;
+use path::{Path,GenericPath};
 use ptr;
 use result::{Result, Ok, Err};
 use str::{StrSlice, OwnedStr};
 use str;
-use to_str::ToStr;
 use uint;
 use vec::{MutableVector, ImmutableVector, OwnedVector, OwnedCopyableVector, CopyableVector};
 use vec;
@@ -1069,7 +1068,9 @@ pub fn file_reader(path: &Path) -> Result<@Reader, ~str> {
     };
 
     if f as uint == 0u {
-        Err(~"error opening " + path.to_str())
+        do path.with_display_str |p| {
+            Err(~"error opening " + p)
+        }
     } else {
         Ok(FILE_reader(f, true))
     }
@@ -1335,7 +1336,7 @@ pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
         }
     };
     if fd < (0 as c_int) {
-        Err(format!("error opening {}: {}", path.to_str(), os::last_os_error()))
+        Err(format!("error opening {}: {}", path.display(), os::last_os_error()))
     } else {
         Ok(fd_writer(fd, true))
     }
@@ -1752,7 +1753,7 @@ pub fn read_whole_file_str(file: &Path) -> Result<~str, ~str> {
         if str::is_utf8(bytes) {
             Ok(str::from_utf8(bytes))
         } else {
-            Err(file.to_str() + " is not UTF-8")
+            Err(file.to_display_str() + " is not UTF-8")
         }
     }
 }
@@ -1892,8 +1893,8 @@ mod tests {
 
     #[test]
     fn test_simple() {
-        let tmpfile = &Path("tmp/lib-io-test-simple.tmp");
-        debug2!("{:?}", tmpfile);
+        let tmpfile = &Path::from_str("tmp/lib-io-test-simple.tmp");
+        debug2!("{}", tmpfile.display());
         let frood: ~str =
             ~"A hoopy frood who really knows where his towel is.";
         debug2!("{}", frood.clone());
@@ -1910,7 +1911,7 @@ mod tests {
     #[test]
     fn test_each_byte_each_char_file() {
         // Issue #5056 -- shouldn't include trailing EOF.
-        let path = Path("tmp/lib-io-test-each-byte-each-char-file.tmp");
+        let path = Path::from_str("tmp/lib-io-test-each-byte-each-char-file.tmp");
 
         {
             // create empty, enough to reproduce a problem
@@ -2010,7 +2011,7 @@ mod tests {
 
     #[test]
     fn file_reader_not_exist() {
-        match io::file_reader(&Path("not a file")) {
+        match io::file_reader(&Path::from_str("not a file")) {
           Err(e) => {
             assert_eq!(e, ~"error opening not a file");
           }
@@ -2021,7 +2022,7 @@ mod tests {
     #[test]
     #[should_fail]
     fn test_read_buffer_too_small() {
-        let path = &Path("tmp/lib-io-test-read-buffer-too-small.tmp");
+        let path = &Path::from_str("tmp/lib-io-test-read-buffer-too-small.tmp");
         // ensure the file exists
         io::file_writer(path, [io::Create]).unwrap();
 
@@ -2032,7 +2033,7 @@ mod tests {
 
     #[test]
     fn test_read_buffer_big_enough() {
-        let path = &Path("tmp/lib-io-test-read-buffer-big-enough.tmp");
+        let path = &Path::from_str("tmp/lib-io-test-read-buffer-big-enough.tmp");
         // ensure the file exists
         io::file_writer(path, [io::Create]).unwrap();
 
@@ -2043,7 +2044,7 @@ mod tests {
 
     #[test]
     fn test_write_empty() {
-        let file = io::file_writer(&Path("tmp/lib-io-test-write-empty.tmp"),
+        let file = io::file_writer(&Path::from_str("tmp/lib-io-test-write-empty.tmp"),
                                    [io::Create]).unwrap();
         file.write([]);
     }
@@ -2075,7 +2076,7 @@ mod tests {
 
     #[test]
     fn test_read_write_le() {
-        let path = Path("tmp/lib-io-test-read-write-le.tmp");
+        let path = Path::from_str("tmp/lib-io-test-read-write-le.tmp");
         let uints = [0, 1, 2, 42, 10_123, 100_123_456, u64::max_value];
 
         // write the ints to the file
@@ -2097,7 +2098,7 @@ mod tests {
 
     #[test]
     fn test_read_write_be() {
-        let path = Path("tmp/lib-io-test-read-write-be.tmp");
+        let path = Path::from_str("tmp/lib-io-test-read-write-be.tmp");
         let uints = [0, 1, 2, 42, 10_123, 100_123_456, u64::max_value];
 
         // write the ints to the file
@@ -2119,7 +2120,7 @@ mod tests {
 
     #[test]
     fn test_read_be_int_n() {
-        let path = Path("tmp/lib-io-test-read-be-int-n.tmp");
+        let path = Path::from_str("tmp/lib-io-test-read-be-int-n.tmp");
         let ints = [i32::min_value, -123456, -42, -5, 0, 1, i32::max_value];
 
         // write the ints to the file
@@ -2143,7 +2144,7 @@ mod tests {
 
     #[test]
     fn test_read_f32() {
-        let path = Path("tmp/lib-io-test-read-f32.tmp");
+        let path = Path::from_str("tmp/lib-io-test-read-f32.tmp");
         //big-endian floating-point 8.1250
         let buf = ~[0x41, 0x02, 0x00, 0x00];
 
@@ -2161,7 +2162,7 @@ mod tests {
 
     #[test]
     fn test_read_write_f32() {
-        let path = Path("tmp/lib-io-test-read-write-f32.tmp");
+        let path = Path::from_str("tmp/lib-io-test-read-write-f32.tmp");
         let f:f32 = 8.1250;
 
         {