Implement ostree::checksum_file_from_input
This commit is contained in:
1 parent
7f3bd56d0d
commit
14f2ff43df
2 files changed
+62
-1
No files matched your search
@@ -32,3 +32,35 @@ pub fn checksum_file<P: IsA<gio::File>, Q: IsA<gio::Cancellable>>(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn checksum_file_from_input<P: IsA<gio::InputStream>, Q: IsA<gio::Cancellable>>(
|
||||
file_info: &gio::FileInfo,
|
||||
xattrs: Option<&glib::Variant>,
|
||||
in_: Option<&P>,
|
||||
objtype: ObjectType,
|
||||
cancellable: Option<&Q>,
|
||||
) -> Result<Checksum, Box<dyn Error>> {
|
||||
unsafe {
|
||||
let mut out_csum = ptr::null_mut();
|
||||
let mut error = ptr::null_mut();
|
||||
let ret = ostree_sys::ostree_checksum_file_from_input(
|
||||
file_info.to_glib_none().0,
|
||||
xattrs.to_glib_none().0,
|
||||
in_.map(|p| p.as_ref()).to_glib_none().0,
|
||||
objtype.to_glib(),
|
||||
&mut out_csum,
|
||||
cancellable.map(|p| p.as_ref()).to_glib_none().0,
|
||||
&mut error,
|
||||
);
|
||||
|
||||
if !error.is_null() {
|
||||
Err(Box::<glib::Error>::new(from_glib_full(error)))
|
||||
} else if ret == GFALSE {
|
||||
Err(Box::new(glib_bool_error!(
|
||||
"unknown error in ostree_checksum_file_from_input"
|
||||
)))
|
||||
} else {
|
||||
Ok(Checksum::from_glib_full(out_csum))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user