about summary refs log tree commit diff
path: root/src/libextra
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2013-10-07 19:16:58 -0700
committerKevin Ballard <kevin@sb.org>2013-10-16 10:26:48 -0700
commitbab7eb20dff32294c65fa28cece552481c40cf0b (patch)
treefc81daee54a1f01c62c792ccbfba362e61d52d76 /src/libextra
parentc01a97b7a981fb5ae008be7e06df4bf6a85eba4f (diff)
downloadrust-bab7eb20dff32294c65fa28cece552481c40cf0b.tar.gz
rust-bab7eb20dff32294c65fa28cece552481c40cf0b.zip
path2: Update based on more review feedback
Standardize the is_sep() functions to be the same in both posix and
windows, and re-export from path. Update extra::glob to use this.

Remove the usage of either, as it's going away.

Move the WindowsPath-specific methods out of WindowsPath and make them
top-level functions of path::windows instead. This way you cannot
accidentally write code that will fail to compile on non-windows
architectures without typing ::windows anywhere.

Remove GenericPath::from_c_str() and just impl BytesContainer for
CString instead.

Remove .join_path() and .push_path() and just implement BytesContainer
for Path instead.

Remove FilenameDisplay and add a boolean flag to Display instead.

Remove .each_parent(). It only had one caller, so just inline its
definition there.
Diffstat (limited to 'src/libextra')
-rw-r--r--src/libextra/glob.rs21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/libextra/glob.rs b/src/libextra/glob.rs
index 1a6c8e08e3b..83456777c40 100644
--- a/src/libextra/glob.rs
+++ b/src/libextra/glob.rs
@@ -24,6 +24,7 @@
  */
 
 use std::{os, path};
+use std::path::is_sep;
 
 use sort;
 
@@ -81,11 +82,7 @@ pub fn glob(pattern: &str) -> GlobIterator {
  */
 pub fn glob_with(pattern: &str, options: MatchOptions) -> GlobIterator {
     #[cfg(windows)]
-    use is_sep = std::path::windows::is_sep2;
-    #[cfg(not(windows))]
-    fn is_sep(c: char) -> bool { c <= '\x7F' && ::std::path::posix::is_sep(&(c as u8)) }
-    #[cfg(windows)]
-    fn check_windows_verbatim(p: &Path) -> bool { p.is_verbatim() }
+    fn check_windows_verbatim(p: &Path) -> bool { path::windows::is_verbatim(p) }
     #[cfg(not(windows))]
     fn check_windows_verbatim(_: &Path) -> bool { false }
 
@@ -98,7 +95,7 @@ pub fn glob_with(pattern: &str, options: MatchOptions) -> GlobIterator {
             // since we can't very well find all UNC shares with a 1-letter server name.
             return GlobIterator { root: root, dir_patterns: ~[], options: options, todo: ~[] };
         }
-        root.push_path(pat_root.get_ref());
+        root.push(pat_root.get_ref());
     }
 
     let root_len = pat_root.map_move_default(0u, |p| p.as_vec().len());
@@ -462,7 +459,7 @@ fn in_char_specifiers(specifiers: &[CharSpecifier], c: char, options: MatchOptio
 
 /// A helper function to determine if two chars are (possibly case-insensitively) equal.
 fn chars_eq(a: char, b: char, case_sensitive: bool) -> bool {
-    if cfg!(windows) && path::windows::is_sep2(a) && path::windows::is_sep2(b) {
+    if cfg!(windows) && path::windows::is_sep(a) && path::windows::is_sep(b) {
         true
     } else if !case_sensitive && a.is_ascii() && b.is_ascii() {
         // FIXME: work with non-ascii chars properly (issue #1347)
@@ -472,16 +469,6 @@ fn chars_eq(a: char, b: char, case_sensitive: bool) -> bool {
     }
 }
 
-/// A helper function to determine if a char is a path separator on the current platform.
-fn is_sep(c: char) -> bool {
-    if cfg!(windows) {
-        path::windows::is_sep2(c)
-    } else {
-        c <= '\x7F' && path::posix::is_sep(&(c as u8))
-    }
-}
-
-
 /**
  * Configuration options to modify the behaviour of `Pattern::matches_with(..)`
  */