Implement fd_filestat_get for all platforms (#42)
* Implement fd_filestat_get for all platforms * Remove an old comment * Remove panics from the syscall wrappers * Return WASI error type * Reuse Metadata if possible to save syscalls. * Refactor the change for two separate fd_filestat_get_impl * Refactor error handling
This commit is contained in:
committed by
Jakub Konka
parent
e759e3c2a4
commit
89fbde2c3f
@@ -6,17 +6,27 @@ cfg_if! {
|
||||
mod unix;
|
||||
pub use self::unix::*;
|
||||
|
||||
pub fn errno_from_host(err: i32) -> host::__wasi_errno_t {
|
||||
pub(crate) fn errno_from_host(err: i32) -> host::__wasi_errno_t {
|
||||
host_impl::errno_from_nix(nix::errno::from_i32(err))
|
||||
}
|
||||
} else if #[cfg(windows)] {
|
||||
mod windows;
|
||||
pub use self::windows::*;
|
||||
|
||||
pub fn errno_from_host(err: i32) -> host::__wasi_errno_t {
|
||||
pub(crate) fn errno_from_host(err: i32) -> host::__wasi_errno_t {
|
||||
host_impl::errno_from_win(winx::winerror::WinError::from_u32(err as u32))
|
||||
}
|
||||
} else {
|
||||
compile_error!("wasi-common doesn't compile for this platform yet");
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn errno_from_ioerror(e: std::io::Error) -> host::__wasi_errno_t {
|
||||
match e.raw_os_error() {
|
||||
Some(code) => errno_from_host(code),
|
||||
None => {
|
||||
log::debug!("Inconvertible OS error: {}", e);
|
||||
host::__WASI_EIO
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user