-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Dynamically compute resource path for macOS app bundle
- Loading branch information
Showing
1 changed file
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
use std::path::PathBuf; | ||
use std::env; | ||
|
||
pub static VERSION: &str = "0.1.0"; | ||
pub static GETTEXT_PACKAGE: &str = "aardvark"; | ||
pub static LOCALEDIR: &str = "/app/share/locale"; | ||
|
||
#[cfg(target_os = "macos")] | ||
pub static PKGDATADIR: &str = "../Resources/share/aardvark"; | ||
pub fn get_pkgdatadir() -> PathBuf { | ||
let exe_path = env::current_exe().expect("Failed to get current executable path"); | ||
|
||
// Navigate to the 'Resources/share/aardvark' directory relative to the executable | ||
let pkgdatadir = exe_path | ||
.parent() // Goes up to 'Contents/MacOS' | ||
.and_then(|p| p.parent()) // Goes up to 'Contents' | ||
.map(|p| p.join("Resources/share/aardvark")) | ||
.expect("Failed to compute PKGDATADIR"); | ||
|
||
pkgdatadir | ||
} | ||
|
||
#[cfg(not(target_os = "macos"))] | ||
pub static PKGDATADIR: &str = "/app/share/aardvark"; | ||
pub fn get_pkgdatadir() -> PathBuf { | ||
PathBuf::from("/app/share/aardvark") | ||
} |