Skip to content

Commit c162ff6

Browse files
Work a little on CC integration
1 parent 3c90679 commit c162ff6

File tree

3 files changed

+207
-0
lines changed

3 files changed

+207
-0
lines changed

Cargo.lock

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ serde = { version = "1.0.210", features = ["derive"] }
1515
serde_json = "1.0.128"
1616
slint = "1.8.0"
1717
tokio = { version = "^1", features = ["rt", "rt-multi-thread"] }
18+
zip = { version = "2.2.0", default-features = false, features = ["bzip2", "deflate", "deflate64", "lzma"] }
1819

1920
[build-dependencies]
2021
slint-build = "1.8.0"

src/cold_clear.rs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use slint::ComponentHandle;
77
use tokio::runtime::Runtime;
88
use crate::dirs::paths;
99
use crate::slint_types::ColdClearWaitWindow;
10+
use zip::ZipArchive;
1011

1112
enum LoadingIPCMessage {
1213
AdvanceTo(
@@ -245,4 +246,85 @@ pub fn download_cold_clear(version: &str) -> Result<(), reqwest::Error> {
245246
window.set_interrupted(true);
246247

247248
return window_thread.join().expect("Failed to join window thread");
249+
}
250+
251+
fn get_path_score(path: &str) -> i8 {
252+
#[cfg(target_arch = "x86_64")]
253+
{
254+
let pos_keywords = [
255+
"x64",
256+
"amd64",
257+
"x86_64"
258+
];
259+
260+
for keyword in pos_keywords.iter() {
261+
if path.contains(keyword) {
262+
return 1;
263+
}
264+
}
265+
266+
let neg_keywords = [
267+
"x86",
268+
"i386",
269+
"i686"
270+
];
271+
272+
for keyword in neg_keywords.iter() {
273+
if path.contains(keyword) {
274+
return -1;
275+
}
276+
}
277+
278+
return 0;
279+
}
280+
281+
#[cfg(target_arch = "x86")]
282+
{
283+
let neg_keywords = [
284+
"x64",
285+
"amd64",
286+
"x86_64"
287+
];
288+
289+
for keyword in neg_keywords.iter() {
290+
if path.contains(keyword) {
291+
return -1;
292+
}
293+
}
294+
295+
let pos_keywords = [
296+
"x86",
297+
"i386",
298+
"i686"
299+
];
300+
301+
for keyword in pos_keywords.iter() {
302+
if path.contains(keyword) {
303+
return 1;
304+
}
305+
}
306+
307+
return 0;
308+
}
309+
310+
#[allow(unreachable_code)]{
311+
return 0;
312+
}
313+
}
314+
315+
pub fn unpack_cold_clear(version: &str) -> Result<(), Box<dyn std::error::Error>> {
316+
let save_path = paths::get_cold_clear_download_path(version);
317+
let save_path = save_path.as_path();
318+
319+
if !save_path.exists() {
320+
download_cold_clear(version)?;
321+
}
322+
323+
let save_path = save_path.to_str().unwrap();
324+
325+
let zip_file = std::fs::File::open(save_path)?;
326+
327+
let mut zip_archive = ZipArchive::new(zip_file)?;
328+
329+
todo!(); // TODO: Extract, flatten, select (path_score) and move library files
248330
}

0 commit comments

Comments
 (0)