aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/main.rs
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-05-13 13:25:05 +0200
committerGitHub <noreply@github.com>2023-05-13 13:25:05 +0200
commit726b7466b34a936205a32098c56b7c723db34862 (patch)
tree0d0e5a725a605dd59ea450300ef28c34be98583c /src-tauri/src/main.rs
parentec0f0a92f8387f4c6d8b314536bc3acdcae56c66 (diff)
downloadFlightCore-726b7466b34a936205a32098c56b7c723db34862.tar.gz
FlightCore-726b7466b34a936205a32098c56b7c723db34862.zip
refactor: Move `extract` function to util submod (#354)
Diffstat (limited to 'src-tauri/src/main.rs')
-rw-r--r--src-tauri/src/main.rs44
1 files changed, 1 insertions, 43 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 7cff8f33..ef041024 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -498,7 +498,7 @@ async fn get_available_northstar_versions() -> Result<Vec<NorthstarThunderstoreR
// As this was causing issues it was moved into `main.rs` until being later moved into dedicated modules
use std::{fs, path::Path};
-use anyhow::{Context, Result};
+use anyhow::Result;
pub mod constants;
mod platform_specific;
@@ -507,7 +507,6 @@ mod platform_specific;
use platform_specific::linux;
use sysinfo::SystemExt;
-use zip::ZipArchive;
use crate::constants::TITANFALL2_STEAM_ID;
@@ -570,47 +569,6 @@ pub fn check_is_valid_game_path(game_install_path: &str) -> Result<(), String> {
Ok(())
}
-/// Copied from `papa` source code and modified
-///Extract N* zip file to target game path
-// fn extract(ctx: &Ctx, zip_file: File, target: &Path) -> Result<()> {
-fn extract(zip_file: std::fs::File, target: &std::path::Path) -> Result<()> {
- let mut archive = ZipArchive::new(&zip_file).context("Unable to open zip archive")?;
- for i in 0..archive.len() {
- let mut f = archive.by_index(i).unwrap();
-
- //This should work fine for N* because the dir structure *should* always be the same
- if f.enclosed_name().unwrap().starts_with("Northstar") {
- let out = target.join(
- f.enclosed_name()
- .unwrap()
- .strip_prefix("Northstar")
- .unwrap(),
- );
-
- if (*f.name()).ends_with('/') {
- log::info!("Create directory {}", f.name());
- std::fs::create_dir_all(target.join(f.name()))
- .context("Unable to create directory")?;
- continue;
- } else if let Some(p) = out.parent() {
- std::fs::create_dir_all(p).context("Unable to create directory")?;
- }
-
- let mut outfile = std::fs::OpenOptions::new()
- .create(true)
- .write(true)
- .truncate(true)
- .open(&out)?;
-
- log::info!("Write file {}", out.display());
-
- std::io::copy(&mut f, &mut outfile).context("Unable to write to file")?;
- }
- }
-
- Ok(())
-}
-
/// Returns identifier of host OS FlightCore is running on
pub fn get_host_os() -> String {
env::consts::OS.to_string()