From c051934446ba575fc6f8c6ab5ccdea3460c95601 Mon Sep 17 00:00:00 2001 From: Yuri Edward Date: Wed, 29 Oct 2025 07:40:01 +0100 Subject: [PATCH 1/2] Fixed bug in get_exe_path --- core/Cargo.toml | 2 +- core/src/assets/apple.rs | 4 ++-- core/src/assets/bsd.rs | 5 +++-- core/src/assets/windows.rs | 2 +- module_test/test_mod/Cargo.toml | 2 +- module_test/testbin/Cargo.toml | 2 +- shelltestbin/Cargo.toml | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) 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..6da0321 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..b2c1a52 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,11 @@ 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() + .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"] } From e173cae0071d9e0142a75de4c03e97657621eec6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 29 Oct 2025 06:45:05 +0000 Subject: [PATCH 2/2] Format Rust code using rustfmt --- core/src/assets/apple.rs | 2 +- core/src/assets/bsd.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/assets/apple.rs b/core/src/assets/apple.rs index 6da0321..777e4e7 100644 --- a/core/src/assets/apple.rs +++ b/core/src/assets/apple.rs @@ -53,7 +53,7 @@ pub fn get_exe_path() -> Option { return None; } let str = OsStr::from_bytes(std::mem::transmute(&v[..size as usize])); - return PathBuf::from(str).parent().map(|v| v.into()) + return PathBuf::from(str).parent().map(|v| v.into()); } if res != 0 { return None; diff --git a/core/src/assets/bsd.rs b/core/src/assets/bsd.rs index b2c1a52..4fcc473 100644 --- a/core/src/assets/bsd.rs +++ b/core/src/assets/bsd.rs @@ -59,8 +59,10 @@ pub fn get_exe_path() -> Option { path.parent().map(|v| v.into()) } else { //FreeBSD with procfs. - std::fs::read_link("/proc/curproc/file").ok() - .map(|v| v.parent().map(PathBuf::from)).flatten() + std::fs::read_link("/proc/curproc/file") + .ok() + .map(|v| v.parent().map(PathBuf::from)) + .flatten() } } }