Add seek support for stdin and stdout
This commit is contained in:
parent
0b824d3a98
commit
a2991cc9c0
@ -231,6 +231,16 @@ impl File for StdoutFile {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn seek(&self, pos: SeekFrom) -> Result<off_t> {
|
||||
let (off, whence) = match pos {
|
||||
SeekFrom::Start(off) => (off as off_t, 0 /* SEEK_SET */),
|
||||
SeekFrom::Current(off) => (off as off_t, 1 /* SEEK_CUR */),
|
||||
SeekFrom::End(off) => (off as off_t, 2 /* SEEK_END */),
|
||||
};
|
||||
let offset = try_libc!(libc::ocall::lseek(self.host_fd() as i32, off, whence));
|
||||
Ok(offset)
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
@ -411,6 +421,16 @@ impl File for StdinFile {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn seek(&self, pos: SeekFrom) -> Result<off_t> {
|
||||
let (off, whence) = match pos {
|
||||
SeekFrom::Start(off) => (off as off_t, 0 /* SEEK_SET */),
|
||||
SeekFrom::Current(off) => (off as off_t, 1 /* SEEK_CUR */),
|
||||
SeekFrom::End(off) => (off as off_t, 2 /* SEEK_END */),
|
||||
};
|
||||
let offset = try_libc!(libc::ocall::lseek(self.host_fd() as i32, off, whence));
|
||||
Ok(offset)
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user