diff --git a/core-foundation-sys/Cargo.toml b/core-foundation-sys/Cargo.toml index da29f1b..769fbc4 100644 --- a/core-foundation-sys/Cargo.toml +++ b/core-foundation-sys/Cargo.toml @@ -3,7 +3,7 @@ name = "core-foundation-sys" description = "Bindings to Core Foundation for OS X" homepage = "https://github.com/servo/core-foundation-rs" repository = "https://github.com/servo/core-foundation-rs" -version = "0.4.0" +version = "0.4.1" authors = ["The Servo Project Developers"] license = "MIT / Apache-2.0" build = "build.rs" diff --git a/core-foundation-sys/src/bundle.rs b/core-foundation-sys/src/bundle.rs index d9eda5d..3f8c0b3 100644 --- a/core-foundation-sys/src/bundle.rs +++ b/core-foundation-sys/src/bundle.rs @@ -32,4 +32,5 @@ extern { pub fn CFBundleGetTypeID() -> CFTypeID; pub fn CFBundleCopyExecutableURL(bundle: CFBundleRef) -> CFURLRef; + pub fn CFBundleCopyPrivateFrameworksURL(bundle: CFBundleRef) -> CFURLRef; } diff --git a/core-foundation/Cargo.toml b/core-foundation/Cargo.toml index 0be8bfb..dd3775b 100644 --- a/core-foundation/Cargo.toml +++ b/core-foundation/Cargo.toml @@ -3,7 +3,7 @@ name = "core-foundation" description = "Bindings to Core Foundation for OS X" homepage = "https://github.com/servo/core-foundation-rs" repository = "https://github.com/servo/core-foundation-rs" -version = "0.4.0" +version = "0.4.1" authors = ["The Servo Project Developers"] license = "MIT / Apache-2.0" diff --git a/core-foundation/src/bundle.rs b/core-foundation/src/bundle.rs index 610ab13..4d75c30 100644 --- a/core-foundation/src/bundle.rs +++ b/core-foundation/src/bundle.rs @@ -63,6 +63,17 @@ impl CFBundle { } } } + + pub fn private_frameworks_url(&self) -> Option { + unsafe { + let fw_url = CFBundleCopyPrivateFrameworksURL(self.0); + if fw_url.is_null() { + None + } else { + Some(TCFType::wrap_under_create_rule(fw_url)) + } + } + } } impl_TCFType!(CFBundle, CFBundleRef, CFBundleGetTypeID); @@ -74,10 +85,35 @@ fn safari_executable_url() { let cfstr_path = CFString::from_static_string("/Applications/Safari.app"); let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true); - let cfurl_executable = CFBundle::new(cfurl_path).expect("Safari not present").executable_url(); + let cfurl_executable = CFBundle::new(cfurl_path) + .expect("Safari not present") + .executable_url(); + assert!(cfurl_executable.is_some()); + assert_eq!(cfurl_executable + .unwrap() + .absolute() + .get_file_system_path(kCFURLPOSIXPathStyle) + .to_string(), + "/Applications/Safari.app/Contents/MacOS/Safari"); +} + +#[test] +fn safari_private_frameworks_url() { + use string::CFString; + use url::{CFURL, kCFURLPOSIXPathStyle}; + + let cfstr_path = CFString::from_static_string("/Applications/Safari.app"); + let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true); + let cfurl_executable = CFBundle::new(cfurl_path) + .expect("Safari not present") + .private_frameworks_url(); assert!(cfurl_executable.is_some()); - assert_eq!(cfurl_executable.unwrap().absolute().get_file_system_path(kCFURLPOSIXPathStyle).to_string(), - "/Applications/Safari.app/Contents/MacOS/Safari"); + assert_eq!(cfurl_executable + .unwrap() + .absolute() + .get_file_system_path(kCFURLPOSIXPathStyle) + .to_string(), + "/Applications/Safari.app/Contents/Frameworks"); } #[test]