From d58b72d211b585735118f606808f1d183d57c532 Mon Sep 17 00:00:00 2001 From: Nikhil Marathe Date: Fri, 16 Jun 2017 09:19:05 -0700 Subject: [PATCH 1/2] Add CFBundle::private_frameworks_url() exposing CFBundleCopyPrivateFrameworksURL(). --- core-foundation-sys/src/bundle.rs | 1 + core-foundation/src/bundle.rs | 42 ++++++++++++++++++++++++++++--- 2 files changed, 40 insertions(+), 3 deletions(-) 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/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] From 650d7a02452024c857b9800c4d67c6c6a65a2e2c Mon Sep 17 00:00:00 2001 From: Nikhil Marathe Date: Fri, 16 Jun 2017 11:01:07 -0700 Subject: [PATCH 2/2] Bump version to 0.4.1 --- core-foundation-sys/Cargo.toml | 2 +- core-foundation/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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"