-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreadme_raw.rs
76 lines (64 loc) · 3.23 KB
/
readme_raw.rs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use everything_sdk::raw::*;
// It looks no different from the ergonomic wrapper, why can't we just write the code like this?
//
// Think about that:
// For any `Everything_*` function as below, we insert another `Everything_*` function between
// them, which will cause the modifications of the mutable global shared states (the underhood
// we know they are just the global static variables in C code), because they all have access
// to them. Finally it will cause _everything_ to become messy, uncontrollable and unreliable.
//
// All we can do is to line them up, in some certain order, and let them move forward one by one
// to prevent chaos.
//
// Ref: <https://stackoverflow.com/questions/27791532/how-do-i-create-a-global-mutable-singleton>
fn main() {
match Everything_IsDBLoaded() {
Some(false) => panic!("The Everything database has not been fully loaded now."),
None => panic!("Everything is required to run in the background."),
_ => {
// Now _Everything_ is OK!
Everything_SetSearch("jpg");
Everything_SetRequestFlags(
RequestFlags::EVERYTHING_REQUEST_FILE_NAME
| RequestFlags::EVERYTHING_REQUEST_PATH
| RequestFlags::EVERYTHING_REQUEST_SIZE
| RequestFlags::EVERYTHING_REQUEST_RUN_COUNT,
);
Everything_SetMax(5);
Everything_SetSort(SortType::EVERYTHING_SORT_DATE_RECENTLY_CHANGED_ASCENDING);
assert_eq!(Everything_GetMatchCase(), false);
Everything_Query(true);
let visible_num_results = dbg!(Everything_GetNumResults());
assert!(visible_num_results <= 5);
let total_num_results = dbg!(Everything_GetTotResults());
assert!(total_num_results >= visible_num_results);
let is_attr_flag_set = dbg!(Everything_GetResultListRequestFlags())
.contains(RequestFlags::EVERYTHING_REQUEST_ATTRIBUTES);
assert!(!is_attr_flag_set);
for index in 0..5 {
let path: std::path::PathBuf = Everything_GetResultPath(index).unwrap().into();
let filename = Everything_GetResultFileName(index).unwrap();
let file_size = Everything_GetResultSize(index).unwrap();
println!(
"Item[{}]: {} ({} bytes)",
index,
path.join(filename).display(), // careful for the "C:abc.txt" without '\'
file_size,
);
}
let run_count = Everything_GetResultRunCount(2);
println!("Run Count for Item[2]: `{}`", run_count);
Everything_SetSearch("cargo");
Everything_Query(true);
}
}
let (major, minor, patch, build, taget) = (
Everything_GetMajorVersion().unwrap(),
Everything_GetMinorVersion().unwrap(),
Everything_GetRevision().unwrap(),
Everything_GetBuildNumber().unwrap(),
Everything_GetTargetMachine().unwrap(),
);
println!("Everything.exe version is {major}.{minor}.{patch}.{build} ({taget})");
let _is_in_appdata = Everything_IsAppData().unwrap();
}