Use char/byte literals instead of single-char/byte string literals.
This commit is contained in:
@@ -110,7 +110,7 @@ impl WasiCtxBuilder {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(k, v)| {
|
.map(|(k, v)| {
|
||||||
let mut pair = k.into_bytes();
|
let mut pair = k.into_bytes();
|
||||||
pair.extend_from_slice(b"=");
|
pair.push(b'=');
|
||||||
pair.extend_from_slice(v.to_bytes_with_nul());
|
pair.extend_from_slice(v.to_bytes_with_nul());
|
||||||
// constructing a new CString from existing CStrings is safe
|
// constructing a new CString from existing CStrings is safe
|
||||||
unsafe { CString::from_vec_unchecked(pair) }
|
unsafe { CString::from_vec_unchecked(pair) }
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ pub(crate) fn path_get(
|
|||||||
Some(cur_path) => {
|
Some(cur_path) => {
|
||||||
log::debug!("cur_path = {:?}", cur_path);
|
log::debug!("cur_path = {:?}", cur_path);
|
||||||
|
|
||||||
let ends_with_slash = cur_path.ends_with("/");
|
let ends_with_slash = cur_path.ends_with('/');
|
||||||
let mut components = Path::new(&cur_path).components();
|
let mut components = Path::new(&cur_path).components();
|
||||||
let head = match components.next() {
|
let head = match components.next() {
|
||||||
None => return Err(host::__WASI_ENOENT),
|
None => return Err(host::__WASI_ENOENT),
|
||||||
@@ -72,7 +72,7 @@ pub(crate) fn path_get(
|
|||||||
if tail.components().next().is_some() {
|
if tail.components().next().is_some() {
|
||||||
let mut tail = host_impl::path_from_host(tail.as_os_str())?;
|
let mut tail = host_impl::path_from_host(tail.as_os_str())?;
|
||||||
if ends_with_slash {
|
if ends_with_slash {
|
||||||
tail.push_str("/");
|
tail.push('/');
|
||||||
}
|
}
|
||||||
path_stack.push(tail);
|
path_stack.push(tail);
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ pub(crate) fn path_get(
|
|||||||
let mut head = host_impl::path_from_host(head)?;
|
let mut head = host_impl::path_from_host(head)?;
|
||||||
if ends_with_slash {
|
if ends_with_slash {
|
||||||
// preserve trailing slash
|
// preserve trailing slash
|
||||||
head.push_str("/");
|
head.push('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
if !path_stack.is_empty() || (ends_with_slash && !needs_final_component) {
|
if !path_stack.is_empty() || (ends_with_slash && !needs_final_component) {
|
||||||
@@ -124,8 +124,8 @@ pub(crate) fn path_get(
|
|||||||
return Err(host::__WASI_ELOOP);
|
return Err(host::__WASI_ELOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if head.ends_with("/") {
|
if head.ends_with('/') {
|
||||||
link_path.push_str("/");
|
link_path.push('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
log::debug!(
|
log::debug!(
|
||||||
@@ -156,8 +156,8 @@ pub(crate) fn path_get(
|
|||||||
return Err(host::__WASI_ELOOP);
|
return Err(host::__WASI_ELOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
if head.ends_with("/") {
|
if head.ends_with('/') {
|
||||||
link_path.push_str("/");
|
link_path.push('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
log::debug!(
|
log::debug!(
|
||||||
|
|||||||
@@ -86,9 +86,9 @@ pub(crate) fn readlinkat(dirfd: &File, s_path: &str) -> Result<String> {
|
|||||||
log::debug!("readlinkat error={:?}", e);
|
log::debug!("readlinkat error={:?}", e);
|
||||||
match WinError::from_u32(e as u32) {
|
match WinError::from_u32(e as u32) {
|
||||||
WinError::ERROR_INVALID_NAME => {
|
WinError::ERROR_INVALID_NAME => {
|
||||||
if s_path.ends_with("/") {
|
if s_path.ends_with('/') {
|
||||||
// strip "/" and check if exists
|
// strip "/" and check if exists
|
||||||
let path = concatenate(dirfd, Path::new(s_path.trim_end_matches("/")))?;
|
let path = concatenate(dirfd, Path::new(s_path.trim_end_matches('/')))?;
|
||||||
if path.exists() && !path.is_dir() {
|
if path.exists() && !path.is_dir() {
|
||||||
Err(host::__WASI_ENOTDIR)
|
Err(host::__WASI_ENOTDIR)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user