@@ -587,7 +587,7 @@ impl GenericPath for PosixPath {
587
587
}
588
588
589
589
fn with_filename ( & self , f : & str ) -> PosixPath {
590
- assert ! ( ! f. iter( ) . all( windows :: is_sep) ) ;
590
+ assert ! ( !f. iter( ) . all( posix :: is_sep) ) ;
591
591
self . dir_path ( ) . push ( f)
592
592
}
593
593
@@ -648,7 +648,7 @@ impl GenericPath for PosixPath {
648
648
fn push_many< S : Str > ( & self , cs : & [ S ] ) -> PosixPath {
649
649
let mut v = self . components . clone ( ) ;
650
650
for cs. iter( ) . advance |e| {
651
- for e. as_slice( ) . split_iter( windows :: is_sep) . advance |s| {
651
+ for e. as_slice( ) . split_iter( posix :: is_sep) . advance |s| {
652
652
if !s. is_empty( ) {
653
653
v. push( s. to_owned( ) )
654
654
}
@@ -662,7 +662,7 @@ impl GenericPath for PosixPath {
662
662
663
663
fn push( & self , s: & str) -> PosixPath {
664
664
let mut v = self . components. clone( ) ;
665
- for s. split_iter( windows :: is_sep) . advance |s| {
665
+ for s. split_iter( posix :: is_sep) . advance |s| {
666
666
if !s. is_empty( ) {
667
667
v. push( s. to_owned( ) )
668
668
}
@@ -1001,7 +1001,17 @@ pub fn normalize(components: &[~str]) -> ~[~str] {
1001
1001
cs
1002
1002
}
1003
1003
1004
- // Various windows helpers, and tests for the impl.
1004
+ // Various posix helpers.
1005
+ pub mod posix {
1006
+
1007
+ #[ inline]
1008
+ pub fn is_sep( u: char) -> bool {
1009
+ u == '/'
1010
+ }
1011
+
1012
+ }
1013
+
1014
+ // Various windows helpers.
1005
1015
pub mod windows {
1006
1016
use libc;
1007
1017
use option : : { None , Option, Some} ;
@@ -1139,6 +1149,14 @@ mod tests {
1139
1149
1140
1150
}
1141
1151
1152
+ #[ test]
1153
+ fn test_posix_push_with_backslash ( ) {
1154
+ let a = PosixPath ( "/aaa/bbb" ) ;
1155
+ let b = a. push ( "x\\ y" ) ; // \ is not a file separator for posix paths
1156
+ assert_eq ! ( a. components. len( ) , 2 ) ;
1157
+ assert_eq ! ( b. components. len( ) , 3 ) ;
1158
+ }
1159
+
1142
1160
#[ test]
1143
1161
fn test_normalize ( ) {
1144
1162
fn t ( wp : & PosixPath , s : & str ) {
0 commit comments