Implement fd_filestat_set_size using libstd
This commit is contained in:
committed by
Jakub Konka
parent
92c2b563fc
commit
e731965fbb
@@ -779,11 +779,7 @@ pub(crate) fn fd_filestat_set_size(
|
|||||||
.and_then(|fe| fe.fd_object.descriptor.as_file())?;
|
.and_then(|fe| fe.fd_object.descriptor.as_file())?;
|
||||||
|
|
||||||
let st_size = dec_filesize(st_size);
|
let st_size = dec_filesize(st_size);
|
||||||
if st_size > i64::max_value() as u64 {
|
fd.set_len(st_size).map_err(errno_from_ioerror)
|
||||||
return Err(host::__WASI_E2BIG);
|
|
||||||
}
|
|
||||||
|
|
||||||
hostcalls_impl::fd_filestat_set_size(fd, st_size)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn path_filestat_get(
|
pub(crate) fn path_filestat_get(
|
||||||
|
|||||||
@@ -406,12 +406,6 @@ pub(crate) fn fd_filestat_set_times(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_filestat_set_size(fd: &File, st_size: host::__wasi_filesize_t) -> Result<()> {
|
|
||||||
use nix::unistd::ftruncate;
|
|
||||||
ftruncate(fd.as_raw_fd(), st_size as off_t)
|
|
||||||
.map_err(|e| host_impl::errno_from_nix(e.as_errno().unwrap()))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn path_filestat_get(
|
pub(crate) fn path_filestat_get(
|
||||||
resolved: PathGet,
|
resolved: PathGet,
|
||||||
dirflags: host::__wasi_lookupflags_t,
|
dirflags: host::__wasi_lookupflags_t,
|
||||||
|
|||||||
@@ -276,10 +276,6 @@ pub(crate) fn fd_filestat_set_times(
|
|||||||
unimplemented!("fd_filestat_set_times")
|
unimplemented!("fd_filestat_set_times")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn fd_filestat_set_size(fd: &File, st_size: host::__wasi_filesize_t) -> Result<()> {
|
|
||||||
unimplemented!("fd_filestat_set_size")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn path_filestat_get(
|
pub(crate) fn path_filestat_get(
|
||||||
resolved: PathGet,
|
resolved: PathGet,
|
||||||
dirflags: host::__wasi_lookupflags_t,
|
dirflags: host::__wasi_lookupflags_t,
|
||||||
|
|||||||
Reference in New Issue
Block a user