@@ -323,6 +323,20 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr {
323
323
mem:: transmute ( s)
324
324
}
325
325
326
+ // Detect scheme on Redox
327
+ #[ inline]
328
+ #[ allow( unused_variables) ]
329
+ fn has_scheme ( s : & [ u8 ] ) -> bool {
330
+ #[ cfg( target_os = "redox" ) ]
331
+ {
332
+ s. split ( |b| * b == b'/' ) . next ( ) . unwrap_or ( b"" ) . contains ( & b':' )
333
+ }
334
+ #[ cfg( not( target_os = "redox" ) ) ]
335
+ {
336
+ false
337
+ }
338
+ }
339
+
326
340
////////////////////////////////////////////////////////////////////////////////
327
341
// Cross-platform, iterator-independent parsing
328
342
////////////////////////////////////////////////////////////////////////////////
@@ -605,6 +619,9 @@ pub struct Components<'a> {
605
619
// normalization, e.g. \\server\share == \\server\share\.
606
620
has_physical_root : bool ,
607
621
622
+ // For Redox
623
+ has_scheme : bool ,
624
+
608
625
// The iterator is double-ended, and these two states keep track of what has
609
626
// been produced from either end
610
627
front : State ,
@@ -725,7 +742,7 @@ impl<'a> Components<'a> {
725
742
726
743
/// Is the *original* path rooted?
727
744
fn has_root ( & self ) -> bool {
728
- if self . has_physical_root {
745
+ if self . has_physical_root || self . has_scheme {
729
746
return true ;
730
747
}
731
748
if let Some ( p) = self . prefix {
@@ -1692,8 +1709,7 @@ impl Path {
1692
1709
#[ cfg( target_os = "redox" ) ]
1693
1710
{
1694
1711
// FIXME: Allow Redox prefixes
1695
- use os:: unix:: ffi:: OsStrExt ;
1696
- self . as_os_str ( ) . as_bytes ( ) . split ( |b| * b == b'/' ) . next ( ) . unwrap_or ( b"" ) . contains ( & b':' )
1712
+ has_scheme ( self . as_u8_slice ( ) )
1697
1713
}
1698
1714
}
1699
1715
@@ -2059,6 +2075,7 @@ impl Path {
2059
2075
path : self . as_u8_slice ( ) ,
2060
2076
prefix,
2061
2077
has_physical_root : has_physical_root ( self . as_u8_slice ( ) , prefix) ,
2078
+ has_scheme : has_scheme ( self . as_u8_slice ( ) ) ,
2062
2079
front : State :: Prefix ,
2063
2080
back : State :: Body ,
2064
2081
}
0 commit comments