Auto merge of #103 - nikhilm:frameworks-path, r=jdm

Add CFBundle::private_frameworks_url() exposing CFBundleCopyPrivateFr…

…ameworksURL().

If this is merged, would it be possible to cut a release after?

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/103)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo
2017-06-16 11:17:18 -07:00
committed by GitHub
4 changed files with 42 additions and 5 deletions
+1 -1
View File
@@ -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"
+1
View File
@@ -32,4 +32,5 @@ extern {
pub fn CFBundleGetTypeID() -> CFTypeID;
pub fn CFBundleCopyExecutableURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopyPrivateFrameworksURL(bundle: CFBundleRef) -> CFURLRef;
}
+1 -1
View File
@@ -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"
+39 -3
View File
@@ -63,6 +63,17 @@ impl CFBundle {
}
}
}
pub fn private_frameworks_url(&self) -> Option<CFURL> {
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");
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/Frameworks");
}
#[test]