fix impl File for Stdin/Stdout
This commit is contained in:
		
							parent
							
								
									26189dddaa
								
							
						
					
					
						commit
						0437e81f36
					
				| @ -22,6 +22,12 @@ impl convert::From<(Errno, &'static str)> for Error { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl convert::From<std::io::Error> for Error { | ||||||
|  |     fn from(info: std::io::Error) -> Error { | ||||||
|  |         Error::new(Errno::from_errno(info.raw_os_error().unwrap()), "std::io::Error") | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| impl error::Error for Error { | impl error::Error for Error { | ||||||
|     fn description(&self) -> &str { |     fn description(&self) -> &str { | ||||||
|         self.desc |         self.desc | ||||||
|  | |||||||
| @ -323,12 +323,12 @@ impl File for StdoutFile { | |||||||
|         Ok(write_len) |         Ok(write_len) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn read_at(&self, offset: usize, buf: &mut [u8]) -> Result<usize, Error> { |     fn read_at(&self, _offset: usize, buf: &mut [u8]) -> Result<usize, Error> { | ||||||
|         unimplemented!() |         self.read(buf) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn write_at(&self, offset: usize, buf: &[u8]) -> Result<usize, Error> { |     fn write_at(&self, _offset: usize, buf: &[u8]) -> Result<usize, Error> { | ||||||
|         unimplemented!() |         self.write(buf) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn readv(&self, bufs: &mut [&mut [u8]]) -> Result<usize, Error> { |     fn readv(&self, bufs: &mut [&mut [u8]]) -> Result<usize, Error> { | ||||||
| @ -364,23 +364,38 @@ impl File for StdoutFile { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn metadata(&self) -> Result<Metadata, Error> { |     fn metadata(&self) -> Result<Metadata, Error> { | ||||||
|         unimplemented!() |         Ok(Metadata { | ||||||
|  |             dev: 0, | ||||||
|  |             inode: 0, | ||||||
|  |             size: 0, | ||||||
|  |             blk_size: 0, | ||||||
|  |             blocks: 0, | ||||||
|  |             atime: Timespec { sec: 0, nsec: 0 }, | ||||||
|  |             mtime: Timespec { sec: 0, nsec: 0 }, | ||||||
|  |             ctime: Timespec { sec: 0, nsec: 0 }, | ||||||
|  |             type_: FileType::File, | ||||||
|  |             mode: 0, | ||||||
|  |             nlinks: 0, | ||||||
|  |             uid: 0, | ||||||
|  |             gid: 0 | ||||||
|  |         }) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn set_len(&self, len: u64) -> Result<(), Error> { |     fn set_len(&self, _len: u64) -> Result<(), Error> { | ||||||
|         unimplemented!() |         errno!(EINVAL, "Stdout does not support set_len") | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn sync_all(&self) -> Result<(), Error> { |     fn sync_all(&self) -> Result<(), Error> { | ||||||
|         unimplemented!() |         self.sync_data() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn sync_data(&self) -> Result<(), Error> { |     fn sync_data(&self) -> Result<(), Error> { | ||||||
|         unimplemented!() |         self.inner.lock().flush()?; | ||||||
|  |         Ok(()) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn read_entry(&self) -> Result<String, Error> { |     fn read_entry(&self) -> Result<String, Error> { | ||||||
|         unimplemented!() |         errno!(ENOTDIR, "Stdout does not support read_entry") | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn as_any(&self) -> &Any { |     fn as_any(&self) -> &Any { | ||||||
| @ -465,23 +480,37 @@ impl File for StdinFile { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn metadata(&self) -> Result<Metadata, Error> { |     fn metadata(&self) -> Result<Metadata, Error> { | ||||||
|         unimplemented!() |         Ok(Metadata { | ||||||
|  |             dev: 0, | ||||||
|  |             inode: 0, | ||||||
|  |             size: 0, | ||||||
|  |             blk_size: 0, | ||||||
|  |             blocks: 0, | ||||||
|  |             atime: Timespec { sec: 0, nsec: 0 }, | ||||||
|  |             mtime: Timespec { sec: 0, nsec: 0 }, | ||||||
|  |             ctime: Timespec { sec: 0, nsec: 0 }, | ||||||
|  |             type_: FileType::File, | ||||||
|  |             mode: 0, | ||||||
|  |             nlinks: 0, | ||||||
|  |             uid: 0, | ||||||
|  |             gid: 0 | ||||||
|  |         }) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn set_len(&self, len: u64) -> Result<(), Error> { |     fn set_len(&self, _len: u64) -> Result<(), Error> { | ||||||
|         unimplemented!() |         errno!(EINVAL, "Stdin does not support set_len") | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn sync_all(&self) -> Result<(), Error> { |     fn sync_all(&self) -> Result<(), Error> { | ||||||
|         unimplemented!() |         self.sync_data() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn sync_data(&self) -> Result<(), Error> { |     fn sync_data(&self) -> Result<(), Error> { | ||||||
|         unimplemented!() |         Ok(()) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn read_entry(&self) -> Result<String, Error> { |     fn read_entry(&self) -> Result<String, Error> { | ||||||
|         unimplemented!() |         errno!(ENOTDIR, "Stdin does not support read_entry") | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     fn as_any(&self) -> &Any { |     fn as_any(&self) -> &Any { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user