diff --git a/src/entry.rs b/src/entry.rs index cce39d45..f79636ac 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -569,7 +569,7 @@ impl<'a> EntryFields<'a> { } return Ok(Unpacked::__Nonexhaustive); - #[cfg(target_arch = "wasm32")] + #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] #[allow(unused_variables)] fn symlink(src: &Path, dst: &Path) -> io::Result<()> { Err(io::Error::new(io::ErrorKind::Other, "Not implemented")) @@ -746,7 +746,7 @@ impl<'a> EntryFields<'a> { } // Windows does not support posix numeric ownership IDs - #[cfg(any(windows, target_arch = "wasm32"))] + #[cfg(not(unix))] fn _set_ownerships( _: &Path, _: &Option<&mut std::fs::File>, @@ -816,7 +816,7 @@ impl<'a> EntryFields<'a> { } } - #[cfg(target_arch = "wasm32")] + #[cfg(all(target_arch = "wasm32", not(all(unix, feature = "xattr"))))] #[allow(unused_variables)] fn _set_perms( dst: &Path, @@ -869,7 +869,11 @@ impl<'a> EntryFields<'a> { } // Windows does not completely support posix xattrs // https://en.wikipedia.org/wiki/Extended_file_attributes#Windows_NT - #[cfg(any(windows, not(feature = "xattr"), target_arch = "wasm32"))] + #[cfg(any( + windows, + not(feature = "xattr"), + all(target_arch = "wasm32", not(target_os = "emscripten")) + ))] fn set_xattrs(_: &mut EntryFields, _: &Path) -> io::Result<()> { Ok(()) } diff --git a/src/header.rs b/src/header.rs index 7e507fc7..1c37f8f0 100644 --- a/src/header.rs +++ b/src/header.rs @@ -732,7 +732,7 @@ impl Header { } } - #[cfg(target_arch = "wasm32")] + #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] #[allow(unused_variables)] fn fill_platform_from(&mut self, meta: &fs::Metadata, mode: HeaderMode) { unimplemented!(); @@ -1546,7 +1546,7 @@ fn copy_path_into(mut slot: &mut [u8], path: &Path, is_link_name: bool) -> io::R } } -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] fn ends_with_slash(p: &Path) -> bool { p.to_string_lossy().ends_with('/') } @@ -1562,7 +1562,7 @@ fn ends_with_slash(p: &Path) -> bool { p.as_os_str().as_bytes().ends_with(&[b'/']) } -#[cfg(any(windows, target_arch = "wasm32"))] +#[cfg(any(windows, all(target_arch = "wasm32", not(target_os = "emscripten"))))] pub fn path2bytes(p: &Path) -> io::Result> { p.as_os_str() .to_str() @@ -1624,19 +1624,19 @@ pub fn bytes2path(bytes: Cow<[u8]>) -> io::Result> { }) } -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] pub fn bytes2path(bytes: Cow<[u8]>) -> io::Result> { Ok(match bytes { Cow::Borrowed(bytes) => { - Cow::Borrowed({ Path::new(str::from_utf8(bytes).map_err(invalid_utf8)?) }) - } - Cow::Owned(bytes) => { - Cow::Owned({ PathBuf::from(String::from_utf8(bytes).map_err(invalid_utf8)?) }) + Cow::Borrowed(Path::new(str::from_utf8(bytes).map_err(invalid_utf8)?)) } + Cow::Owned(bytes) => Cow::Owned(PathBuf::from( + String::from_utf8(bytes).map_err(invalid_utf8)?, + )), }) } -#[cfg(target_arch = "wasm32")] +#[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] fn invalid_utf8(_: T) -> io::Error { io::Error::new(io::ErrorKind::InvalidData, "Invalid utf-8") }