Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CFBundle::private_frameworks_url() exposing CFBundleCopyPrivateFr… #103

Merged
merged 2 commits into from Jun 16, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -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"
@@ -32,4 +32,5 @@ extern {

pub fn CFBundleGetTypeID() -> CFTypeID;
pub fn CFBundleCopyExecutableURL(bundle: CFBundleRef) -> CFURLRef;
pub fn CFBundleCopyPrivateFrameworksURL(bundle: CFBundleRef) -> CFURLRef;
}
@@ -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"

@@ -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");
}

#[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]
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.