add is_library_available command

This commit is contained in:
Thien Tran 2025-06-03 15:15:57 +08:00 committed by Louis
parent 622f4118c0
commit 1eb49350e9
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2
3 changed files with 14 additions and 1 deletions

View File

@ -56,9 +56,9 @@ serde_yaml = "0.9.34"
hmac = "0.12.1"
sha2 = "0.10.9"
base64 = "0.22.1"
libloading = "0.8.7"
[target.'cfg(windows)'.dependencies]
libloading = "0.8.7"
libc = "0.2.172"
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]

View File

@ -151,3 +151,15 @@ pub fn decompress(app: tauri::AppHandle, path: &str, output_dir: &str) -> Result
Ok(())
}
// check if a system library is available
#[tauri::command]
pub fn is_library_available(library: &str) -> bool {
match unsafe { libloading::Library::new(library) } {
Ok(_) => true,
Err(e) => {
log::info!("Library {} is not available: {}", library, e);
false
}
}
}

View File

@ -83,6 +83,7 @@ pub fn run() {
core::utils::write_yaml,
core::utils::read_yaml,
core::utils::decompress,
core::utils::is_library_available,
// Download
core::utils::download::download_files,
core::utils::download::cancel_download_task,