Skip to content

Commit

Permalink
fix: Linux version home_dir add root slash
Browse files Browse the repository at this point in the history
  • Loading branch information
MissterHao committed Nov 29, 2022
1 parent 684bf3f commit 542d159
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/common/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl SystemPaths {
.expect("failed to execute process")
}

#[cfg(target_os = "windows")]
pub fn home_dir() -> String {
let output = SystemPaths::user_home_dir();

Expand All @@ -30,6 +31,15 @@ impl SystemPaths {
home.to_string().replace("\\\\", "\\")
}

#[cfg(target_os = "linux")]
pub fn home_dir() -> String {
let output = SystemPaths::user_home_dir();

let home = strip_trailing_newline(str::from_utf8(&output.stdout).unwrap());

format!("/{}", home.to_string().replace("\\\\", "\\"))
}

#[cfg(target_os = "windows")]
pub fn vscode_workspace_storage_path() -> String {
let home = SystemPaths::home_dir();
Expand Down

0 comments on commit 542d159

Please sign in to comment.