diff options
| author | FenrirWolf <[email protected]> | 2018-03-04 22:21:50 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2018-03-04 22:21:50 -0700 |
| commit | c95c3289f80e0596834d02e63d09178b744ccf86 (patch) | |
| tree | c8d9250e6051baeb6cb9739aa548701ac7cdb34f /ctr-std/src | |
| parent | Update to nightly-2018-03-01 (diff) | |
| download | ctru-rs-c95c3289f80e0596834d02e63d09178b744ccf86.tar.xz ctru-rs-c95c3289f80e0596834d02e63d09178b744ccf86.zip | |
Make std::path aware of archive prefixes (#61)
Diffstat (limited to 'ctr-std/src')
| -rw-r--r-- | ctr-std/src/path.rs | 8 | ||||
| -rw-r--r-- | ctr-std/src/sys/unix/path.rs | 12 |
2 files changed, 16 insertions, 4 deletions
diff --git a/ctr-std/src/path.rs b/ctr-std/src/path.rs index e03a182..2b76a2d 100644 --- a/ctr-std/src/path.rs +++ b/ctr-std/src/path.rs @@ -201,6 +201,9 @@ impl<'a> Prefix<'a> { os_str_as_u8_slice(s).len() } match *self { + #[cfg(target_os = "horizon")] + Verbatim(x) => 1 + os_str_len(x), + #[cfg(target_os = "windows")] Verbatim(x) => 4 + os_str_len(x), VerbatimUNC(x, y) => { 8 + os_str_len(x) + @@ -325,7 +328,8 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr { // Detect scheme on Redox fn has_redox_scheme(s: &[u8]) -> bool { - cfg!(target_os = "redox") && s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':') + (cfg!(target_os = "redox") || cfg!(target_os = "horizon")) + && s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':') } //////////////////////////////////////////////////////////////////////////////// @@ -1736,7 +1740,7 @@ impl Path { #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] pub fn is_absolute(&self) -> bool { - if cfg!(target_os = "redox") { + if cfg!(target_os = "redox") || cfg!(target_os = "horizon") { // FIXME: Allow Redox prefixes self.has_root() || has_redox_scheme(self.as_u8_slice()) } else { diff --git a/ctr-std/src/sys/unix/path.rs b/ctr-std/src/sys/unix/path.rs index 395b8c1..d96473b 100644 --- a/ctr-std/src/sys/unix/path.rs +++ b/ctr-std/src/sys/unix/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::Verbatim(OsStr::new(&path_str[..i]))) + } else { + None + } + } else { + None + } } pub const MAIN_SEP_STR: &'static str = "/"; |