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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
pub mod archive;
pub mod consts;
pub mod error;
pub mod file;
mod macros;
pub mod source;
pub use archive::*;
pub use error::{Error, ZResult};
pub type Stat = zip_stat_t;
use error::ZipErrorSys;
use zipp_sys::*;
use libc::{mktime, time_t};
use std::{ffi::CStr, mem::zeroed};
pub fn version() -> &'static str {
let ver = unsafe { CStr::from_ptr(zip_libzip_version()) };
ver.to_str().unwrap()
}
pub fn cal_mtime(sec: i32, min: i32, hour: i32, day: i32, mon: i32, year: i32) -> time_t {
let mut tm: libc::tm = unsafe { zeroed() };
tm.tm_sec = sec;
tm.tm_min = min;
tm.tm_hour = hour;
tm.tm_mday = day;
tm.tm_mon = mon - 1;
tm.tm_year = year - 1900;
unsafe { mktime(&mut tm) }
}
pub fn compression_method_supported(method: i32, is_comp: bool) -> bool {
unsafe { zip_compression_method_supported(method, is_comp as _) == 1 }
}
pub fn encryption_method_supported(method: u16, is_encrypt: bool) -> bool {
unsafe { zip_encryption_method_supported(method, is_encrypt as _) == 1 }
}