Skip to content

Commit

Permalink
keep the original configuration of the host
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwin612 committed Jun 19, 2023
1 parent 9efd599 commit 0d33007
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion env/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "portable_runner_env"
version = "0.0.1"
version = "0.0.2"
authors = ["kerwin612 <kerwin612@qq.com>"]

[dependencies]
Expand Down
15 changes: 12 additions & 3 deletions env/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern crate mount_dir;
extern crate random_string;

use std::env::{set_var};
use std::process::Command;
use std::env::{var, set_var};
use std::fs::{remove_dir_all};
use std::path::{Component, Path};
use std::os::windows::process::CommandExt;
Expand Down Expand Up @@ -36,6 +36,17 @@ pub fn mount(tpath: &str, lpath: &str, hpath: &str, force: bool) -> Result<bool,
let local_app_data = format!("{}\\Local", &app_data);
let temp = format!("{}\\Temp", &local_app_data);

set_var("PORTABLE_RUNNER_ENV_LINK_PATH", &lpath);
set_var("PORTABLE_RUNNER_ENV_TARGET_PATH", &tpath);
set_var("PORTABLE_RUNNER_HOST_TMP", var("TMP").unwrap_or("".to_string()));
set_var("PORTABLE_RUNNER_HOST_TEMP", var("TEMP").unwrap_or("".to_string()));
set_var("PORTABLE_RUNNER_HOST_HOME", var("HOME").unwrap_or("".to_string()));
set_var("PORTABLE_RUNNER_HOST_APPDATA", var("APPDATA").unwrap_or("".to_string()));
set_var("PORTABLE_RUNNER_HOST_HOMEPATH", var("HOMEPATH").unwrap_or("".to_string()));
set_var("PORTABLE_RUNNER_HOST_HOMEDRIVE", var("HOMEDRIVE").unwrap_or("".to_string()));
set_var("PORTABLE_RUNNER_HOST_USERPROFILE", var("USERPROFILE").unwrap_or("".to_string()));
set_var("PORTABLE_RUNNER_HOST_LOCALAPPDATA", var("LOCALAPPDATA").unwrap_or("".to_string()));

set_var("TMP", &temp);
set_var("TEMP", &temp);
set_var("HOME", &_hpath);
Expand All @@ -44,8 +55,6 @@ pub fn mount(tpath: &str, lpath: &str, hpath: &str, force: bool) -> Result<bool,
set_var("HOMEDRIVE", get_disk(lpath));
set_var("APPDATA", &roaming_app_data);
set_var("LOCALAPPDATA", &local_app_data);
set_var("PORTABLE_RUNNER_ENV_LINK_PATH", &lpath);
set_var("PORTABLE_RUNNER_ENV_TARGET_PATH", &tpath);

let mut profile_path = format!("{}\\.profile.cmd", &_hpath);
if ! Path::new(&profile_path).exists() {
Expand Down
2 changes: 1 addition & 1 deletion gui/src-tauri/Cargo.lock

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

0 comments on commit 0d33007

Please sign in to comment.