Skip to content

Commit

Permalink
CFBundleCopyResourcesDirectoryURL
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhr committed Oct 14, 2020
1 parent d2ff402 commit 437be24
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions core-foundation-sys/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ extern {
pub fn CFBundleCopyPrivateFrameworksURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopySharedSupportURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopyBundleURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopyResourcesDirectoryURL(bundle: CFBundleRef) -> CFURLRef;
}
18 changes: 18 additions & 0 deletions core-foundation/src/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ impl CFBundle {
Some(PathBuf::from(url.get_file_system_path(kCFURLPOSIXPathStyle).to_string()))
}

/// Bundle's resources location
pub fn bundle_resources_url(&self) -> Option<CFURL> {
unsafe {
let bundle_url = CFBundleCopyResourcesDirectoryURL(self.0);
if bundle_url.is_null() {
None
} else {
Some(TCFType::wrap_under_create_rule(bundle_url))
}
}
}

/// Bundle's resources location
pub fn resources_path(&self) -> Option<PathBuf> {
let url = self.bundle_resources_url()?;
Some(PathBuf::from(url.get_file_system_path(kCFURLPOSIXPathStyle).to_string()))
}

pub fn private_frameworks_url(&self) -> Option<CFURL> {
unsafe {
let fw_url = CFBundleCopyPrivateFrameworksURL(self.0);
Expand Down

0 comments on commit 437be24

Please sign in to comment.