We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3f723cf commit b8608b4Copy full SHA for b8608b4
src/reader.rs
@@ -63,6 +63,20 @@ pub trait Reader : Handle {
63
}
64
65
66
+impl Read for Reader {
67
+ fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
68
+ let cbuf = buf.as_mut_ptr() as *mut c_void;
69
+ unsafe {
70
+ match ffi::archive_read_data(self.handle(), cbuf, buf.len()) {
71
+ n if n >= 0 => Ok(n as usize),
72
+ // Libarchive returns OS errors, but has more specific error strings (err_msg()).
73
+ // Not sure how to include that in the io::Error struct.
74
+ _ => Err(io::Error::from_raw_os_error(self.err_code().0)),
75
+ }
76
77
78
+}
79
+
80
pub struct FileReader {
81
handle: *mut ffi::Struct_archive,
82
entry: ReaderEntry,
0 commit comments