Merge branch 'use-redox-path-in-cwd' into 'master'
Use redox_path in canonicalize_using_cwd_internal See merge request redox-os/relibc!669
This commit is contained in:
Generated
+2
-2
@@ -432,9 +432,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox-path"
|
||||
version = "0.2.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64072665120942deff5fd5425d6c1811b854f4939e7f1c01ce755f64432bbea7"
|
||||
checksum = "436d45c2b6a5b159d43da708e62b25be3a4a3d5550d654b72216ade4c4bfd717"
|
||||
|
||||
[[package]]
|
||||
name = "redox-rt"
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ sc = "0.2.3"
|
||||
[target.'cfg(target_os = "redox")'.dependencies]
|
||||
redox_syscall = "0.5.13"
|
||||
redox-rt = { path = "redox-rt" }
|
||||
redox-path = "0.2"
|
||||
redox-path = "0.3"
|
||||
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git", default-features = false, features = [
|
||||
"redox_syscall",
|
||||
] }
|
||||
|
||||
@@ -5,7 +5,7 @@ use syscall::{data::Stat, error::*, flag::*};
|
||||
use super::{libcscheme, FdGuard};
|
||||
use crate::sync::Mutex;
|
||||
|
||||
pub use redox_path::canonicalize_using_cwd;
|
||||
pub use redox_path::{canonicalize_using_cwd, canonicalize_using_scheme, RedoxPath};
|
||||
|
||||
// TODO: Define in syscall
|
||||
const PATH_MAX: usize = 4096;
|
||||
@@ -77,27 +77,16 @@ pub fn set_default_scheme(scheme: &str) -> Result<()> {
|
||||
fn canonicalize_with_cwd_internal(cwd: Option<&str>, path: &str) -> Result<String> {
|
||||
let path = canonicalize_using_cwd(cwd, path).ok_or(Error::new(ENOENT))?;
|
||||
|
||||
let standard_scheme = path == "/scheme" || path.starts_with("/scheme/");
|
||||
let legacy_scheme = path
|
||||
.split("/")
|
||||
.next()
|
||||
.map(|c| c.contains(":"))
|
||||
.unwrap_or(false);
|
||||
|
||||
Ok(if standard_scheme || legacy_scheme {
|
||||
path
|
||||
if RedoxPath::from_absolute(&path)
|
||||
.map(|rpath| rpath.is_legacy() || path.starts_with("/scheme/"))
|
||||
.unwrap_or_default()
|
||||
{
|
||||
Ok(path)
|
||||
} else {
|
||||
let mut default_scheme_guard = DEFAULT_SCHEME.lock();
|
||||
let default_scheme = default_scheme_guard.get_or_insert_with(|| Box::from("file"));
|
||||
let mut result = format!("/scheme/{}{}", default_scheme, path);
|
||||
|
||||
// Trim trailing / to keep path canonical.
|
||||
if result.as_bytes().last() == Some(&b'/') {
|
||||
result.pop();
|
||||
}
|
||||
|
||||
result
|
||||
})
|
||||
canonicalize_using_scheme(default_scheme, &path).ok_or(Error::new(ENOENT))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn canonicalize(path: &str) -> Result<String> {
|
||||
|
||||
Reference in New Issue
Block a user