about summary refs log tree commit diff
path: root/src/libextra
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/libextra
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/libextra')
-rw-r--r--src/libextra/fileinput.rs16
-rw-r--r--src/libextra/glob.rs8
-rw-r--r--src/libextra/tempfile.rs2
-rw-r--r--src/libextra/terminfo/searcher.rs16
-rw-r--r--src/libextra/test.rs8
-rw-r--r--src/libextra/workcache.rs2
6 files changed, 26 insertions, 26 deletions
diff --git a/src/libextra/fileinput.rs b/src/libextra/fileinput.rs
index 08d1222ff46..8f176d5ccea 100644
--- a/src/libextra/fileinput.rs
+++ b/src/libextra/fileinput.rs
@@ -358,11 +358,11 @@ instance. `stdin_hyphen` controls whether `-` represents `stdin` or
 a literal `-`.
 */
 pub fn make_path_option_vec(vec: &[~str], stdin_hyphen : bool) -> ~[Option<Path>] {
-    vec.iter().map(|str| {
-        if stdin_hyphen && "-" == *str {
+    vec.iter().map(|s| {
+        if stdin_hyphen && "-" == *s {
             None
         } else {
-            Some(Path::from_str(*str))
+            Some(Path::new(s.as_slice()))
         }
     }).collect()
 }
@@ -435,14 +435,14 @@ mod test {
     fn test_make_path_option_vec() {
         let strs = [~"some/path",
                     ~"some/other/path"];
-        let paths = ~[Some(Path::from_str("some/path")),
-                      Some(Path::from_str("some/other/path"))];
+        let paths = ~[Some(Path::new("some/path")),
+                      Some(Path::new("some/other/path"))];
 
         assert_eq!(make_path_option_vec(strs, true), paths.clone());
         assert_eq!(make_path_option_vec(strs, false), paths);
 
         assert_eq!(make_path_option_vec([~"-"], true), ~[None]);
-        assert_eq!(make_path_option_vec([~"-"], false), ~[Some(Path::from_str("-"))]);
+        assert_eq!(make_path_option_vec([~"-"], false), ~[Some(Path::new("-"))]);
     }
 
     #[test]
@@ -567,9 +567,9 @@ mod test {
     #[test]
     fn test_no_trailing_newline() {
         let f1 =
-            Some(Path::from_str("tmp/lib-fileinput-test-no-trailing-newline-1.tmp"));
+            Some(Path::new("tmp/lib-fileinput-test-no-trailing-newline-1.tmp"));
         let f2 =
-            Some(Path::from_str("tmp/lib-fileinput-test-no-trailing-newline-2.tmp"));
+            Some(Path::new("tmp/lib-fileinput-test-no-trailing-newline-2.tmp"));
 
         {
             let mut wr = file::open(f1.get_ref(), io::CreateOrTruncate,
diff --git a/src/libextra/glob.rs b/src/libextra/glob.rs
index 51a4718394e..1a6c8e08e3b 100644
--- a/src/libextra/glob.rs
+++ b/src/libextra/glob.rs
@@ -91,7 +91,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> GlobIterator {
 
     // calculate root this way to handle volume-relative Windows paths correctly
     let mut root = os::getcwd();
-    let pat_root = Path::from_str(pattern).root_path();
+    let pat_root = Path::new(pattern).root_path();
     if pat_root.is_some() {
         if check_windows_verbatim(pat_root.get_ref()) {
             // XXX: How do we want to handle verbatim paths? I'm inclined to return nothing,
@@ -548,7 +548,7 @@ mod test {
         assert!(glob("//").next().is_none());
 
         // check windows absolute paths with host/device components
-        let root_with_device = os::getcwd().root_path().unwrap().join_str("*");
+        let root_with_device = os::getcwd().root_path().unwrap().join("*");
         // FIXME (#9639): This needs to handle non-utf8 paths
         assert!(glob(root_with_device.as_str().unwrap()).next().is_some());
     }
@@ -772,9 +772,9 @@ mod test {
 
     #[test]
     fn test_matches_path() {
-        // on windows, (Path::from_str("a/b").as_str().unwrap() == "a\\b"), so this
+        // on windows, (Path::new("a/b").as_str().unwrap() == "a\\b"), so this
         // tests that / and \ are considered equivalent on windows
-        assert!(Pattern::new("a/b").matches_path(&Path::from_str("a/b")));
+        assert!(Pattern::new("a/b").matches_path(&Path::new("a/b")));
     }
 }
 
diff --git a/src/libextra/tempfile.rs b/src/libextra/tempfile.rs
index 12263188787..d8fa130916a 100644
--- a/src/libextra/tempfile.rs
+++ b/src/libextra/tempfile.rs
@@ -35,7 +35,7 @@ impl TempDir {
 
         let mut r = rand::rng();
         for _ in range(0u, 1000) {
-            let p = tmpdir.join_str(r.gen_ascii_str(16) + suffix);
+            let p = tmpdir.join(r.gen_ascii_str(16) + suffix);
             if os::make_dir(&p, 0x1c0) { // 700
                 return Some(TempDir { path: Some(p) });
             }
diff --git a/src/libextra/terminfo/searcher.rs b/src/libextra/terminfo/searcher.rs
index cd4e487d70f..ea7d20e096d 100644
--- a/src/libextra/terminfo/searcher.rs
+++ b/src/libextra/terminfo/searcher.rs
@@ -28,26 +28,26 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~Path> {
 
     // Find search directory
     match getenv("TERMINFO") {
-        Some(dir) => dirs_to_search.push(Path::from_str(dir)),
+        Some(dir) => dirs_to_search.push(Path::new(dir)),
         None => {
             if homedir.is_some() {
                 // ncurses compatability;
-                dirs_to_search.push(homedir.unwrap().join_str(".terminfo"))
+                dirs_to_search.push(homedir.unwrap().join(".terminfo"))
             }
             match getenv("TERMINFO_DIRS") {
                 Some(dirs) => for i in dirs.split_iter(':') {
                     if i == "" {
-                        dirs_to_search.push(Path::from_str("/usr/share/terminfo"));
+                        dirs_to_search.push(Path::new("/usr/share/terminfo"));
                     } else {
-                        dirs_to_search.push(Path::from_str(i.to_owned()));
+                        dirs_to_search.push(Path::new(i.to_owned()));
                     }
                 },
                 // Found nothing, use the default paths
                 // /usr/share/terminfo is the de facto location, but it seems
                 // Ubuntu puts it in /lib/terminfo
                 None => {
-                    dirs_to_search.push(Path::from_str("/usr/share/terminfo"));
-                    dirs_to_search.push(Path::from_str("/lib/terminfo"));
+                    dirs_to_search.push(Path::new("/usr/share/terminfo"));
+                    dirs_to_search.push(Path::new("/lib/terminfo"));
                 }
             }
         }
@@ -57,13 +57,13 @@ pub fn get_dbpath_for_term(term: &str) -> Option<~Path> {
     for p in dirs_to_search.iter() {
         if os::path_exists(p) {
             let f = str::from_char(first_char);
-            let newp = p.join_many_str([f.as_slice(), term]);
+            let newp = p.join_many([f.as_slice(), term]);
             if os::path_exists(&newp) {
                 return Some(~newp);
             }
             // on some installations the dir is named after the hex of the char (e.g. OS X)
             let f = format!("{:x}", first_char as uint);
-            let newp = p.join_many_str([f.as_slice(), term]);
+            let newp = p.join_many([f.as_slice(), term]);
             if os::path_exists(&newp) {
                 return Some(~newp);
             }
diff --git a/src/libextra/test.rs b/src/libextra/test.rs
index 20690283dd5..21fa9ed7574 100644
--- a/src/libextra/test.rs
+++ b/src/libextra/test.rs
@@ -271,20 +271,20 @@ pub fn parse_opts(args: &[~str]) -> Option<OptRes> {
     let run_ignored = matches.opt_present("ignored");
 
     let logfile = matches.opt_str("logfile");
-    let logfile = logfile.map(|s| Path::from_str(s));
+    let logfile = logfile.map(|s| Path::new(s));
 
     let run_benchmarks = matches.opt_present("bench");
     let run_tests = ! run_benchmarks ||
         matches.opt_present("test");
 
     let ratchet_metrics = matches.opt_str("ratchet-metrics");
-    let ratchet_metrics = ratchet_metrics.map(|s| Path::from_str(s));
+    let ratchet_metrics = ratchet_metrics.map(|s| Path::new(s));
 
     let ratchet_noise_percent = matches.opt_str("ratchet-noise-percent");
     let ratchet_noise_percent = ratchet_noise_percent.map(|s| from_str::<f64>(s).unwrap());
 
     let save_metrics = matches.opt_str("save-metrics");
-    let save_metrics = save_metrics.map(|s| Path::from_str(s));
+    let save_metrics = save_metrics.map(|s| Path::new(s));
 
     let test_shard = matches.opt_str("test-shard");
     let test_shard = opt_shard(test_shard);
@@ -1440,7 +1440,7 @@ mod tests {
     pub fn ratchet_test() {
 
         let dpth = TempDir::new("test-ratchet").expect("missing test for ratchet");
-        let pth = dpth.path().join_str("ratchet.json");
+        let pth = dpth.path().join("ratchet.json");
 
         let mut m1 = MetricMap::new();
         m1.insert_metric("runtime", 1000.0, 2.0);
diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs
index ea943cdb01b..26309cf3b37 100644
--- a/src/libextra/workcache.rs
+++ b/src/libextra/workcache.rs
@@ -498,7 +498,7 @@ fn test() {
     // Create a path to a new file 'filename' in the directory in which
     // this test is running.
     fn make_path(filename: ~str) -> Path {
-        let pth = os::self_exe_path().expect("workcache::test failed").with_filename_str(filename);
+        let pth = os::self_exe_path().expect("workcache::test failed").with_filename(filename);
         if os::path_exists(&pth) {
             os::remove_file(&pth);
         }