Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Support #9

Merged
merged 3 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ authors = ["WillKirkmanM <WillKirkmanMoller@gmail.com>"]
[dependencies]
clap = { version = "4.2.4", features = ["derive"] }
colored = "2.0.0"
dylib = "0.0.3"
flate2 = "1.0.25"
flate2 = "1.0.26"
indicatif = "0.17.3"
reqwest = "0.11.17"
serde = { version = "1.0.160", features = ["derive"] }
Expand Down
11 changes: 10 additions & 1 deletion src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::path::Path;
use std::thread;
use std::time::Duration;
use std::fs;
use std::env;
use std::{cmp::min, fmt::Write};


Expand All @@ -17,7 +18,15 @@ use colored::Colorize;
use crate::get_path;

pub async fn download_environment(id: String) -> Result<(), Box<dyn Error>> {
let base_path = "/usr/share/sandbox/beaches/";
let base_path = match env::consts::OS {
"windows" => {
let appdata = std::env::var("appdata").unwrap();
let beaches_path = format!("{}/sandbox/beaches/", appdata);
beaches_path
}
_ => "/usr/share/sandbox/beaches/".to_string()
};

let environment_path = get_path(id.clone()).await;

let download_url = format!("https://github.com/the-sandbox-project/sandbox-templates/raw/master/{}", environment_path);
Expand Down
13 changes: 12 additions & 1 deletion src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ pub async fn open_environment(environment: String) {

let path = get_path(environment.clone()).await;
let environment_path = path.split("/").collect::<Vec<&str>>()[0].to_owned() + "/" + &environment;
let beaches_path = format!("/usr/share/sandbox/beaches/{}", environment_path);

let beaches_path = match env::consts::OS {
"windows" => {
let appdata = std::env::var("appdata").unwrap();
let beaches_path = format!("{}/sandbox/beaches/{}", appdata, environment_path);
beaches_path
}
_ => {
let beaches_path = format!("/usr/share/sandbox/beaches/{}", environment_path);
beaches_path
}
};

env::set_current_dir(beaches_path).unwrap();
Command::new(editor)
Expand Down