1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
mod fd_flags;
mod file_io_ext;
use crate::io::IsReadWrite;
pub use fd_flags::{FdFlags, GetSetFdFlags, SetFdFlags};
pub use file_io_ext::{Advice, FileIoExt};
impl crate::io::ReadReady for std::fs::File {
#[inline]
fn num_ready_bytes(&self) -> std::io::Result<u64> {
let (read, _write) = self.is_read_write()?;
if read {
let metadata = self.metadata()?;
if metadata.is_file() {
return Ok(metadata.len());
}
}
Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"stream is not readable",
))
}
}