kplayer_rust_wrap/kplayer/util/
os.rs1#[allow(dead_code)]
2extern "C" {
3 fn FileExist(p: i32) -> i32;
4 fn PrintLog(level: i32, p: i32) -> i32;
5 fn NowTimestamp() -> i64;
6}
7
8#[allow(dead_code)]
9pub fn file_exist(file_path: &String) -> bool {
10 let str_i = super::string::DynamicString::from(file_path.as_bytes()).get_index();
11 unsafe {
12 if FileExist(str_i) == 0 {
13 return false;
14 }
15 }
16 true
17}
18
19#[allow(dead_code)]
20pub enum PrintLogLevel {
21 INFO,
22 ERROR,
23 DEBUG,
24}
25
26#[allow(dead_code)]
27pub fn now_timestamp() -> i64 {
28 unsafe { NowTimestamp() }
29}
30
31#[allow(dead_code)]
32pub fn print_log(level: PrintLogLevel, str: &String) {
33 let str_i = super::string::DynamicString::from(str.as_bytes()).get_index();
34 unsafe {
35 PrintLog(level as i32, str_i);
36 }
37}