Reuse errno_from_ioerror to simplify error handling

This commit is contained in:
Marcin Mielniczuk
2019-08-08 17:30:19 +02:00
committed by Jakub Konka
parent e18175c556
commit 92c2b563fc
8 changed files with 31 additions and 55 deletions

View File

@@ -1,4 +1,4 @@
use crate::sys::{errno_from_host, fdentry_impl};
use crate::sys::{errno_from_ioerror, fdentry_impl};
use crate::{host, Result};
use std::mem::ManuallyDrop;
@@ -92,7 +92,7 @@ impl FdEntry {
pub fn duplicate(file: &fs::File) -> Result<Self> {
file.try_clone()
.map_err(|err| err.raw_os_error().map_or(host::__WASI_EIO, errno_from_host))
.map_err(errno_from_ioerror)
.and_then(Self::from)
}