Skip to content
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
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bp3d-os"
version = "2.1.0"
version = "2.2.0"
authors = ["Yuri Edward <[email protected]>"]
edition = "2021"
description = "Operating System tools designed for BlockProject3D"
Expand Down
41 changes: 38 additions & 3 deletions core/src/assets/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2023, BlockProject 3D
// Copyright (c) 2025, BlockProject 3D
//
// All rights reserved.
//
Expand Down Expand Up @@ -71,9 +71,44 @@ use windows::{get_exe_path, get_resources_dir};
pub fn get_app_bundled_asset(file_name: &str) -> Option<PathBuf> {
let res = get_resources_dir()
.map(|v| v.join(file_name))
.or_else(|| get_exe_path().map(|v| v.join("Assets").join(file_name)));
.or_else(|| get_exe_path().map(|v| v.join("..").join("Assets").join(file_name)));
if res.as_ref().map(|v| !v.exists()).unwrap_or(false) {
return None;
let res = get_exe_path().map(|v| v.join("Assets").join(file_name));
if res.as_ref().map(|v| !v.exists()).unwrap_or(false) {
return None;
}
return res;
}
res
}

/// Returns the path to the executable. This is useful for loading assets in CLI based applications.
///
/// # Platform specific behavior
///
/// On supported platforms this returns the path to the current executing program.
/// Supported platforms are:
/// - Any Linux/Unix with a procfs,
/// - macOS,
/// - iOS
///
/// Returns None if there is a system issue, ex: the system didn't return a proper path to the current
/// executing application. This should rarely occur.
pub fn get_executable_path() -> Option<PathBuf> {
get_exe_path()
}

#[cfg(test)]
mod tests {
use crate::assets::{get_app_bundled_asset, get_executable_path};

#[test]
fn test() {
assert!(get_executable_path().is_some());
}

#[test]
fn test2() {
assert!(get_app_bundled_asset("file.txt").is_none());
}
}
2 changes: 1 addition & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

//! Operating System tools and extensions designed for BlockProject3D.

#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs)]

#[cfg(feature = "dirs")]
Expand Down
2 changes: 1 addition & 1 deletion module_test/test_mod/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ crate-type = ["rlib", "cdylib"]
bp3d-os-build = { version = "1.1.0", path = "../../build" }

[dependencies]
bp3d-os = { version = "2.1.0", path = "../../core", features = ["module"] }
bp3d-os = { version = "2.2.0", path = "../../core", features = ["module"] }
bp3d-debug = "1.0.0"
2 changes: 1 addition & 1 deletion module_test/testbin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ edition = "2024"
publish = false

[dependencies]
bp3d-os = { version = "2.1.0", path = "../../core", features = ["module"] }
bp3d-os = { version = "2.2.0", path = "../../core", features = ["module"] }
2 changes: 1 addition & 1 deletion shelltestbin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ edition = "2024"
publish = false

[dependencies]
bp3d-os = { version = "2.0.0", path = "../core", features = ["shell"] }
bp3d-os = { version = "2.2.0", path = "../core", features = ["shell"] }