Skip to content

Commit

Permalink
Work a little on CC integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Not-A-Normal-Robot committed Oct 31, 2024
1 parent 3c90679 commit c162ff6
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 0 deletions.
124 changes: 124 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.128"
slint = "1.8.0"
tokio = { version = "^1", features = ["rt", "rt-multi-thread"] }
zip = { version = "2.2.0", default-features = false, features = ["bzip2", "deflate", "deflate64", "lzma"] }

[build-dependencies]
slint-build = "1.8.0"
82 changes: 82 additions & 0 deletions src/cold_clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use slint::ComponentHandle;
use tokio::runtime::Runtime;
use crate::dirs::paths;
use crate::slint_types::ColdClearWaitWindow;
use zip::ZipArchive;

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

return window_thread.join().expect("Failed to join window thread");
}

fn get_path_score(path: &str) -> i8 {
#[cfg(target_arch = "x86_64")]
{
let pos_keywords = [
"x64",
"amd64",
"x86_64"
];

for keyword in pos_keywords.iter() {
if path.contains(keyword) {
return 1;
}
}

let neg_keywords = [
"x86",
"i386",
"i686"
];

for keyword in neg_keywords.iter() {
if path.contains(keyword) {
return -1;
}
}

return 0;
}

#[cfg(target_arch = "x86")]
{
let neg_keywords = [
"x64",
"amd64",
"x86_64"
];

for keyword in neg_keywords.iter() {
if path.contains(keyword) {
return -1;
}
}

let pos_keywords = [
"x86",
"i386",
"i686"
];

for keyword in pos_keywords.iter() {
if path.contains(keyword) {
return 1;
}
}

return 0;
}

#[allow(unreachable_code)]{
return 0;
}
}

pub fn unpack_cold_clear(version: &str) -> Result<(), Box<dyn std::error::Error>> {
let save_path = paths::get_cold_clear_download_path(version);
let save_path = save_path.as_path();

if !save_path.exists() {
download_cold_clear(version)?;
}

let save_path = save_path.to_str().unwrap();

let zip_file = std::fs::File::open(save_path)?;

let mut zip_archive = ZipArchive::new(zip_file)?;

todo!(); // TODO: Extract, flatten, select (path_score) and move library files
}

0 comments on commit c162ff6

Please sign in to comment.