diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /third_party/rust/core-foundation/src/bundle.rs | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/core-foundation/src/bundle.rs')
-rw-r--r-- | third_party/rust/core-foundation/src/bundle.rs | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/third_party/rust/core-foundation/src/bundle.rs b/third_party/rust/core-foundation/src/bundle.rs index b9ab1f65f6..f6d53a991f 100644 --- a/third_party/rust/core-foundation/src/bundle.rs +++ b/third_party/rust/core-foundation/src/bundle.rs @@ -14,13 +14,13 @@ pub use core_foundation_sys::bundle::*; use core_foundation_sys::url::kCFURLPOSIXPathStyle; use std::path::PathBuf; -use base::{CFType, TCFType}; -use url::CFURL; -use dictionary::CFDictionary; +use crate::base::{CFType, TCFType}; +use crate::dictionary::CFDictionary; +use crate::string::CFString; +use crate::url::CFURL; use std::os::raw::c_void; -use string::CFString; -declare_TCFType!{ +declare_TCFType! { /// A Bundle type. CFBundle, CFBundleRef } @@ -51,8 +51,10 @@ impl CFBundle { pub fn function_pointer_for_name(&self, function_name: CFString) -> *const c_void { unsafe { - CFBundleGetFunctionPointerForName(self.as_concrete_TypeRef(), - function_name.as_concrete_TypeRef()) + CFBundleGetFunctionPointerForName( + self.as_concrete_TypeRef(), + function_name.as_concrete_TypeRef(), + ) } } @@ -96,7 +98,9 @@ impl CFBundle { /// Bundle's own location pub fn path(&self) -> Option<PathBuf> { let url = self.bundle_url()?; - Some(PathBuf::from(url.get_file_system_path(kCFURLPOSIXPathStyle).to_string())) + Some(PathBuf::from( + url.get_file_system_path(kCFURLPOSIXPathStyle).to_string(), + )) } /// Bundle's resources location @@ -114,7 +118,9 @@ impl CFBundle { /// 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())) + Some(PathBuf::from( + url.get_file_system_path(kCFURLPOSIXPathStyle).to_string(), + )) } pub fn private_frameworks_url(&self) -> Option<CFURL> { @@ -140,11 +146,10 @@ impl CFBundle { } } - #[test] fn safari_executable_url() { - use string::CFString; - use url::{CFURL, kCFURLPOSIXPathStyle}; + use crate::string::CFString; + use crate::url::{kCFURLPOSIXPathStyle, CFURL}; let cfstr_path = CFString::from_static_string("/Applications/Safari.app"); let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true); @@ -152,18 +157,20 @@ fn safari_executable_url() { .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}; + use crate::string::CFString; + use crate::url::{kCFURLPOSIXPathStyle, CFURL}; let cfstr_path = CFString::from_static_string("/Applications/Safari.app"); let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true); @@ -171,18 +178,20 @@ fn safari_private_frameworks_url() { .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"); + assert_eq!( + cfurl_executable + .unwrap() + .absolute() + .get_file_system_path(kCFURLPOSIXPathStyle) + .to_string(), + "/Applications/Safari.app/Contents/Frameworks" + ); } #[test] fn non_existant_bundle() { - use string::CFString; - use url::{CFURL, kCFURLPOSIXPathStyle}; + use crate::string::CFString; + use crate::url::{kCFURLPOSIXPathStyle, CFURL}; let cfstr_path = CFString::from_static_string("/usr/local/foo"); let cfurl_path = CFURL::from_file_system_path(cfstr_path, kCFURLPOSIXPathStyle, true); |