about summary refs log tree commit diff
path: root/src/libstd/rt/io
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2013-10-05 19:49:32 -0700
committerKevin Ballard <kevin@sb.org>2013-10-15 22:18:30 -0700
commitd6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd (patch)
treee197783b86700e71d94c9bc6d0254eb25b16cc0c /src/libstd/rt/io
parented539e14712539473c3e89604cb69e2307110772 (diff)
downloadrust-d6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd.tar.gz
rust-d6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd.zip
path2: Adjust the API to remove all the _str mutation methods
Add a new trait BytesContainer that is implemented for both byte vectors
and strings.

Convert Path::from_vec and ::from_str to one function, Path::new().

Remove all the _str-suffixed mutation methods (push, join, with_*,
set_*) and modify the non-suffixed versions to use BytesContainer.
Diffstat (limited to 'src/libstd/rt/io')
-rw-r--r--src/libstd/rt/io/file.rs28
-rw-r--r--src/libstd/rt/io/support.rs2
2 files changed, 15 insertions, 15 deletions
diff --git a/src/libstd/rt/io/file.rs b/src/libstd/rt/io/file.rs
index 9fbb897c2a7..39c3c5692f8 100644
--- a/src/libstd/rt/io/file.rs
+++ b/src/libstd/rt/io/file.rs
@@ -703,7 +703,7 @@ mod test {
     fn file_test_io_smoke_test() {
         do run_in_mt_newsched_task {
             let message = "it's alright. have a good time";
-            let filename = &Path::from_str("./tmp/file_rt_io_file_test.txt");
+            let filename = &Path::new("./tmp/file_rt_io_file_test.txt");
             {
                 let mut write_stream = open(filename, Create, ReadWrite).unwrap();
                 write_stream.write(message.as_bytes());
@@ -725,7 +725,7 @@ mod test {
     #[test]
     fn file_test_io_invalid_path_opened_without_create_should_raise_condition() {
         do run_in_mt_newsched_task {
-            let filename = &Path::from_str("./tmp/file_that_does_not_exist.txt");
+            let filename = &Path::new("./tmp/file_that_does_not_exist.txt");
             let mut called = false;
             do io_error::cond.trap(|_| {
                 called = true;
@@ -740,7 +740,7 @@ mod test {
     #[test]
     fn file_test_iounlinking_invalid_path_should_raise_condition() {
         do run_in_mt_newsched_task {
-            let filename = &Path::from_str("./tmp/file_another_file_that_does_not_exist.txt");
+            let filename = &Path::new("./tmp/file_another_file_that_does_not_exist.txt");
             let mut called = false;
             do io_error::cond.trap(|_| {
                 called = true;
@@ -757,7 +757,7 @@ mod test {
             use str;
             let message = "ten-four";
             let mut read_mem = [0, .. 8];
-            let filename = &Path::from_str("./tmp/file_rt_io_file_test_positional.txt");
+            let filename = &Path::new("./tmp/file_rt_io_file_test_positional.txt");
             {
                 let mut rw_stream = open(filename, Create, ReadWrite).unwrap();
                 rw_stream.write(message.as_bytes());
@@ -788,7 +788,7 @@ mod test {
             let set_cursor = 4 as u64;
             let mut tell_pos_pre_read;
             let mut tell_pos_post_read;
-            let filename = &Path::from_str("./tmp/file_rt_io_file_test_seeking.txt");
+            let filename = &Path::new("./tmp/file_rt_io_file_test_seeking.txt");
             {
                 let mut rw_stream = open(filename, Create, ReadWrite).unwrap();
                 rw_stream.write(message.as_bytes());
@@ -817,7 +817,7 @@ mod test {
             let final_msg =     "foo-the-bar!!";
             let seek_idx = 3;
             let mut read_mem = [0, .. 13];
-            let filename = &Path::from_str("./tmp/file_rt_io_file_test_seek_and_write.txt");
+            let filename = &Path::new("./tmp/file_rt_io_file_test_seek_and_write.txt");
             {
                 let mut rw_stream = open(filename, Create, ReadWrite).unwrap();
                 rw_stream.write(initial_msg.as_bytes());
@@ -843,7 +843,7 @@ mod test {
             let chunk_two = "asdf";
             let chunk_three = "zxcv";
             let mut read_mem = [0, .. 4];
-            let filename = &Path::from_str("./tmp/file_rt_io_file_test_seek_shakedown.txt");
+            let filename = &Path::new("./tmp/file_rt_io_file_test_seek_shakedown.txt");
             {
                 let mut rw_stream = open(filename, Create, ReadWrite).unwrap();
                 rw_stream.write(initial_msg.as_bytes());
@@ -873,7 +873,7 @@ mod test {
     #[test]
     fn file_test_stat_is_correct_on_is_file() {
         do run_in_mt_newsched_task {
-            let filename = &Path::from_str("./tmp/file_stat_correct_on_is_file.txt");
+            let filename = &Path::new("./tmp/file_stat_correct_on_is_file.txt");
             {
                 let mut fs = open(filename, Create, ReadWrite).unwrap();
                 let msg = "hw";
@@ -891,7 +891,7 @@ mod test {
     #[test]
     fn file_test_stat_is_correct_on_is_dir() {
         do run_in_mt_newsched_task {
-            let filename = &Path::from_str("./tmp/file_stat_correct_on_is_dir");
+            let filename = &Path::new("./tmp/file_stat_correct_on_is_dir");
             mkdir(filename);
             let stat_res = match stat(filename) {
                 Some(s) => s,
@@ -905,7 +905,7 @@ mod test {
     #[test]
     fn file_test_fileinfo_false_when_checking_is_file_on_a_directory() {
         do run_in_mt_newsched_task {
-            let dir = &Path::from_str("./tmp/fileinfo_false_on_dir");
+            let dir = &Path::new("./tmp/fileinfo_false_on_dir");
             mkdir(dir);
             assert!(dir.is_file() == false);
             rmdir(dir);
@@ -915,7 +915,7 @@ mod test {
     #[test]
     fn file_test_fileinfo_check_exists_before_and_after_file_creation() {
         do run_in_mt_newsched_task {
-            let file = &Path::from_str("./tmp/fileinfo_check_exists_b_and_a.txt");
+            let file = &Path::new("./tmp/fileinfo_check_exists_b_and_a.txt");
             {
                 let msg = "foo".as_bytes();
                 let mut w = file.open_writer(Create);
@@ -930,7 +930,7 @@ mod test {
     #[test]
     fn file_test_directoryinfo_check_exists_before_and_after_mkdir() {
         do run_in_mt_newsched_task {
-            let dir = &Path::from_str("./tmp/before_and_after_dir");
+            let dir = &Path::new("./tmp/before_and_after_dir");
             assert!(!dir.exists());
             dir.mkdir();
             assert!(dir.exists());
@@ -944,11 +944,11 @@ mod test {
     fn file_test_directoryinfo_readdir() {
         use str;
         do run_in_mt_newsched_task {
-            let dir = &Path::from_str("./tmp/di_readdir");
+            let dir = &Path::new("./tmp/di_readdir");
             dir.mkdir();
             let prefix = "foo";
             for n in range(0,3) {
-                let f = dir.join_str(format!("{}.txt", n));
+                let f = dir.join(format!("{}.txt", n));
                 let mut w = f.open_writer(Create);
                 let msg_str = (prefix + n.to_str().to_owned()).to_owned();
                 let msg = msg_str.as_bytes();
diff --git a/src/libstd/rt/io/support.rs b/src/libstd/rt/io/support.rs
index a872423c255..31040bc51a1 100644
--- a/src/libstd/rt/io/support.rs
+++ b/src/libstd/rt/io/support.rs
@@ -35,7 +35,7 @@ mod test {
     #[test]
     fn path_like_smoke_test() {
         let expected = if cfg!(unix) { "/home" } else { "C:\\" };
-        let path = Path::from_str(expected);
+        let path = Path::new(expected);
         path.path_as_str(|p| assert!(p == expected));
         path.path_as_str(|p| assert!(p == expected));
     }