-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uses total files for progress when installing a PKG (#758)
- Loading branch information
1 parent
ea3380c
commit 9b3c26c
Showing
9 changed files
with
171 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
#![allow(clippy::enum_variant_names)] | ||
|
||
// The purpose of this crate is to generate a static library to link with the GUI. So it is required | ||
// to add other crates that expose API to the GUI as a dependency of this crate then re-export all | ||
// of those APIs here. | ||
pub use error::*; | ||
pub use pkg::*; | ||
|
||
mod ffi; | ||
mod fwdl; | ||
mod param; | ||
mod pkg; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use error::Error; | ||
use param::Param; | ||
use pkg::Pkg; | ||
use std::ffi::{c_char, c_void, CStr}; | ||
use std::ptr::null_mut; | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn pkg_open(file: *const c_char, error: *mut *mut Error) -> *mut Pkg { | ||
let path = CStr::from_ptr(file); | ||
let pkg = match Pkg::open(path.to_str().unwrap()) { | ||
Ok(v) => Box::new(v), | ||
Err(e) => { | ||
*error = Error::new(e); | ||
return null_mut(); | ||
} | ||
}; | ||
|
||
Box::into_raw(pkg) | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn pkg_close(pkg: *mut Pkg) { | ||
drop(Box::from_raw(pkg)); | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn pkg_get_param(pkg: &Pkg, error: *mut *mut Error) -> *mut Param { | ||
let param = match pkg.get_param() { | ||
Ok(v) => Box::new(v), | ||
Err(e) => { | ||
*error = Error::new(e); | ||
return null_mut(); | ||
} | ||
}; | ||
|
||
Box::into_raw(param) | ||
} | ||
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn pkg_extract( | ||
pkg: &Pkg, | ||
dir: *const c_char, | ||
status: extern "C" fn(*const c_char, usize, usize, *mut c_void), | ||
ud: *mut c_void, | ||
) -> *mut Error { | ||
let dir = CStr::from_ptr(dir); | ||
|
||
match pkg.extract(dir.to_str().unwrap(), status, ud) { | ||
Ok(_) => null_mut(), | ||
Err(e) => Error::new(e), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.