diff --git a/core/Cargo.toml b/core/Cargo.toml index 74afae0..3a7ddd6 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bp3d-os" -version = "2.2.0" +version = "2.2.1" authors = ["Yuri Edward "] edition = "2021" description = "Operating System tools designed for BlockProject3D" diff --git a/core/src/assets/apple.rs b/core/src/assets/apple.rs index 40a6445..777e4e7 100644 --- a/core/src/assets/apple.rs +++ b/core/src/assets/apple.rs @@ -53,14 +53,14 @@ pub fn get_exe_path() -> Option { return None; } let str = OsStr::from_bytes(std::mem::transmute(&v[..size as usize])); - return Some(PathBuf::from(str)); + return PathBuf::from(str).parent().map(|v| v.into()); } if res != 0 { return None; } let len = strlen(buf.as_ptr()); let str = OsStr::from_bytes(std::mem::transmute(&buf[..len])); - Some(PathBuf::from(str)) + PathBuf::from(str).parent().map(|v| v.into()) } } diff --git a/core/src/assets/bsd.rs b/core/src/assets/bsd.rs index 75f48ed..4fcc473 100644 --- a/core/src/assets/bsd.rs +++ b/core/src/assets/bsd.rs @@ -1,4 +1,4 @@ -// Copyright (c) 2023, BlockProject 3D +// Copyright (c) 2025, BlockProject 3D // // All rights reserved. // @@ -56,10 +56,13 @@ pub fn get_exe_path() -> Option { //This is where we defer from process_path: we use std::os::unix::ffi::OsStrExt. let str = OsStr::from_bytes(&buf[..len]); let path = PathBuf::from(str); - Some(path) + path.parent().map(|v| v.into()) } else { //FreeBSD with procfs. - std::fs::read_link("/proc/curproc/file").ok() + std::fs::read_link("/proc/curproc/file") + .ok() + .map(|v| v.parent().map(PathBuf::from)) + .flatten() } } } diff --git a/core/src/assets/windows.rs b/core/src/assets/windows.rs index 16f0455..aa3a0b6 100644 --- a/core/src/assets/windows.rs +++ b/core/src/assets/windows.rs @@ -67,7 +67,7 @@ pub fn get_exe_path() -> Option { } //We finally found the executable file name! let str1 = OsString::from_wide(&buf[..res as usize]); - Some(str1.into()) + Some(PathBuf::from(str1).parent()?.into()) } } diff --git a/module_test/test_mod/Cargo.toml b/module_test/test_mod/Cargo.toml index aba9413..5b98bd0 100644 --- a/module_test/test_mod/Cargo.toml +++ b/module_test/test_mod/Cargo.toml @@ -11,5 +11,5 @@ crate-type = ["rlib", "cdylib"] bp3d-os-build = { version = "1.1.0", path = "../../build" } [dependencies] -bp3d-os = { version = "2.2.0", path = "../../core", features = ["module"] } +bp3d-os = { version = "2.2.1", path = "../../core", features = ["module"] } bp3d-debug = "1.0.0" diff --git a/module_test/testbin/Cargo.toml b/module_test/testbin/Cargo.toml index 96ffc46..e21a19e 100644 --- a/module_test/testbin/Cargo.toml +++ b/module_test/testbin/Cargo.toml @@ -5,4 +5,4 @@ edition = "2024" publish = false [dependencies] -bp3d-os = { version = "2.2.0", path = "../../core", features = ["module"] } +bp3d-os = { version = "2.2.1", path = "../../core", features = ["module"] } diff --git a/shelltestbin/Cargo.toml b/shelltestbin/Cargo.toml index 883808e..59f5dae 100644 --- a/shelltestbin/Cargo.toml +++ b/shelltestbin/Cargo.toml @@ -5,4 +5,4 @@ edition = "2024" publish = false [dependencies] -bp3d-os = { version = "2.2.0", path = "../core", features = ["shell"] } +bp3d-os = { version = "2.2.1", path = "../core", features = ["shell"] }