2019-03-21 15:55:23 +00:00
|
|
|
use crate::vfs::file_like::{FileLike, Metadata};
|
|
|
|
use failure::Error;
|
2019-03-26 02:43:52 +00:00
|
|
|
use std::io;
|
2019-03-21 15:55:23 +00:00
|
|
|
|
|
|
|
pub struct Stdin;
|
|
|
|
pub struct Stdout;
|
|
|
|
pub struct Stderr;
|
|
|
|
|
|
|
|
impl FileLike for Stdin {
|
2019-03-26 02:43:52 +00:00
|
|
|
fn metadata(&self) -> Result<Metadata, Error> {
|
|
|
|
unimplemented!()
|
2019-03-21 15:55:23 +00:00
|
|
|
}
|
|
|
|
|
2019-03-28 19:50:37 +00:00
|
|
|
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
|
|
|
|
panic!("Cannot set length of stdin");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl io::Read for Stdin {
|
|
|
|
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
|
2019-03-21 15:55:23 +00:00
|
|
|
unimplemented!()
|
|
|
|
}
|
2019-03-28 19:50:37 +00:00
|
|
|
}
|
2019-03-28 18:41:45 +00:00
|
|
|
|
2019-03-28 19:50:37 +00:00
|
|
|
impl io::Write for Stdin {
|
|
|
|
fn write(&mut self, _buf: &[u8]) -> Result<usize, io::Error> {
|
2019-03-28 18:41:45 +00:00
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
2019-03-28 19:50:37 +00:00
|
|
|
fn flush(&mut self) -> Result<(), io::Error> {
|
|
|
|
unimplemented!()
|
2019-03-28 18:41:45 +00:00
|
|
|
}
|
2019-03-26 02:43:52 +00:00
|
|
|
}
|
2019-03-21 15:55:23 +00:00
|
|
|
|
2019-03-28 18:41:45 +00:00
|
|
|
impl io::Seek for Stdin {
|
|
|
|
fn seek(&mut self, _pos: io::SeekFrom) -> Result<u64, io::Error> {
|
2019-03-26 02:43:52 +00:00
|
|
|
unimplemented!()
|
2019-03-21 15:55:23 +00:00
|
|
|
}
|
2019-03-26 02:43:52 +00:00
|
|
|
}
|
2019-03-21 15:55:23 +00:00
|
|
|
|
2019-03-26 02:43:52 +00:00
|
|
|
impl FileLike for Stdout {
|
|
|
|
fn metadata(&self) -> Result<Metadata, failure::Error> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
2019-03-28 19:50:37 +00:00
|
|
|
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
|
|
|
|
panic!("Cannot set length of stdout");
|
2019-03-26 02:43:52 +00:00
|
|
|
}
|
2019-03-28 19:50:37 +00:00
|
|
|
}
|
2019-03-28 18:41:45 +00:00
|
|
|
|
2019-03-28 19:50:37 +00:00
|
|
|
impl io::Read for Stdout {
|
|
|
|
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
|
2019-03-28 18:41:45 +00:00
|
|
|
unimplemented!()
|
|
|
|
}
|
2019-03-28 19:50:37 +00:00
|
|
|
}
|
2019-03-28 18:41:45 +00:00
|
|
|
|
2019-03-28 19:50:37 +00:00
|
|
|
impl io::Write for Stdout {
|
|
|
|
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
|
|
|
|
let stdout = io::stdout();
|
|
|
|
let mut handle = stdout.lock();
|
|
|
|
handle.write(buf)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn flush(&mut self) -> Result<(), io::Error> {
|
|
|
|
let stdout = io::stdout();
|
|
|
|
let mut handle = stdout.lock();
|
|
|
|
handle.flush()
|
2019-03-28 18:41:45 +00:00
|
|
|
}
|
2019-03-26 02:43:52 +00:00
|
|
|
}
|
|
|
|
|
2019-03-28 18:41:45 +00:00
|
|
|
impl io::Seek for Stdout {
|
|
|
|
fn seek(&mut self, _pos: io::SeekFrom) -> Result<u64, io::Error> {
|
2019-03-26 02:43:52 +00:00
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl FileLike for Stderr {
|
|
|
|
fn metadata(&self) -> Result<Metadata, failure::Error> {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
|
2019-03-28 19:50:37 +00:00
|
|
|
fn set_file_len(&mut self, _len: usize) -> Result<(), failure::Error> {
|
|
|
|
panic!("Cannot set length of stderr");
|
2019-03-26 02:43:52 +00:00
|
|
|
}
|
2019-03-28 19:50:37 +00:00
|
|
|
}
|
2019-03-28 18:41:45 +00:00
|
|
|
|
2019-03-28 19:50:37 +00:00
|
|
|
impl io::Read for Stderr {
|
|
|
|
fn read(&mut self, _buf: &mut [u8]) -> Result<usize, io::Error> {
|
2019-03-28 18:41:45 +00:00
|
|
|
unimplemented!()
|
|
|
|
}
|
2019-03-28 19:50:37 +00:00
|
|
|
}
|
2019-03-28 18:41:45 +00:00
|
|
|
|
2019-03-28 19:50:37 +00:00
|
|
|
impl io::Write for Stderr {
|
|
|
|
fn write(&mut self, buf: &[u8]) -> Result<usize, io::Error> {
|
|
|
|
let stderr = io::stderr();
|
|
|
|
let mut handle = stderr.lock();
|
|
|
|
handle.write(buf)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn flush(&mut self) -> Result<(), io::Error> {
|
|
|
|
let stderr = io::stderr();
|
|
|
|
let mut handle = stderr.lock();
|
|
|
|
handle.flush()
|
2019-03-28 18:41:45 +00:00
|
|
|
}
|
2019-03-26 02:43:52 +00:00
|
|
|
}
|
|
|
|
|
2019-03-28 18:41:45 +00:00
|
|
|
impl io::Seek for Stderr {
|
|
|
|
fn seek(&mut self, _pos: io::SeekFrom) -> Result<u64, io::Error> {
|
2019-03-21 15:55:23 +00:00
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|