about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorJeremy Soller <jackpot51@gmail.com>2016-11-14 15:02:18 -0700
committerJeremy Soller <jackpot51@gmail.com>2016-11-14 15:02:18 -0700
commit18bf0540bf8a04a5724dd515fec2311d1e4768e4 (patch)
tree7f48774d3ace2796260f16966f22a932de81caf9 /src/libstd
parenta0b5dfef2a36a15f76476a9d6bb7184a701d0d3c (diff)
downloadrust-18bf0540bf8a04a5724dd515fec2311d1e4768e4.tar.gz
rust-18bf0540bf8a04a5724dd515fec2311d1e4768e4.zip
Fix redox prefix handling
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/path.rs9
-rw-r--r--src/libstd/sys/redox/path.rs12
2 files changed, 18 insertions, 3 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index bb6883236e8..3e414a28a30 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -129,7 +129,9 @@ use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
 // Windows Prefixes
 ////////////////////////////////////////////////////////////////////////////////
 
-/// Path prefixes (Windows only).
+/// Path prefixes (Redox and Windows only).
+///
+/// Redox uses schemes like `scheme:reference` to identify different I/O systems
 ///
 /// Windows uses a variety of path styles, including references to drive
 /// volumes (like `C:`), network shared folders (like `\\server\share`) and
@@ -139,6 +141,10 @@ use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
 #[derive(Copy, Clone, Debug, Hash, PartialOrd, Ord, PartialEq, Eq)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub enum Prefix<'a> {
+    /// Prefix `scheme:`, where `scheme` is the component stored
+    #[unstable(feature="redox_prefix", issue="0")]
+    Scheme(&'a OsStr),
+
     /// Prefix `\\?\`, together with the given component immediately following it.
     #[stable(feature = "rust1", since = "1.0.0")]
     Verbatim(#[stable(feature = "rust1", since = "1.0.0")] &'a OsStr),
@@ -178,6 +184,7 @@ impl<'a> Prefix<'a> {
             os_str_as_u8_slice(s).len()
         }
         match *self {
+            Scheme(x) => os_str_len(x) + 1,
             Verbatim(x) => 4 + os_str_len(x),
             VerbatimUNC(x, y) => {
                 8 + os_str_len(x) +
diff --git a/src/libstd/sys/redox/path.rs b/src/libstd/sys/redox/path.rs
index bf9af7a4353..4069a0ea726 100644
--- a/src/libstd/sys/redox/path.rs
+++ b/src/libstd/sys/redox/path.rs
@@ -21,8 +21,16 @@ pub fn is_verbatim_sep(b: u8) -> bool {
     b == b'/'
 }
 
-pub fn parse_prefix(_: &OsStr) -> Option<Prefix> {
-    None
+pub fn parse_prefix(path: &OsStr) -> Option<Prefix> {
+    if let Some(path_str) = path.to_str() {
+        if let Some(i) = path_str.find(':') {
+            Some(Prefix::Scheme(OsStr::new(&path_str[..i])))
+        } else {
+            None
+        }
+    } else {
+        None
+    }
 }
 
 pub const MAIN_SEP_STR: &'static str = "/";