Skip to content

Commit 55a4d79

Browse files
author
bors-servo
authored
Auto merge of #274 - acheronfail:chore/add-cf-bookmark-definitions, r=jdm
chore: add CF functions for using bookmark data fixes #116 (a closed issue) Provides the definitions for some of the CF functions for using Bookmark data (which is useful for sandboxed applications). <!-- 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/274) <!-- Reviewable:end -->
2 parents e24f144 + cf356f6 commit 55a4d79

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

core-foundation-sys/src/url.rs

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
use std::os::raw::c_void;
1111

1212
use base::{CFOptionFlags, CFIndex, CFAllocatorRef, Boolean, CFTypeID, CFTypeRef, SInt32};
13+
use data::CFDataRef;
14+
use array::CFArrayRef;
15+
use dictionary::CFDictionaryRef;
1316
use string::{CFStringRef, CFStringEncoding};
1417
use error::CFErrorRef;
1518

@@ -19,6 +22,8 @@ pub struct __CFURL(c_void);
1922
pub type CFURLRef = *const __CFURL;
2023

2124
pub type CFURLBookmarkCreationOptions = CFOptionFlags;
25+
pub type CFURLBookmarkResolutionOptions = CFOptionFlags;
26+
pub type CFURLBookmarkFileCreationOptions = CFOptionFlags;
2227

2328
pub type CFURLPathStyle = CFIndex;
2429

@@ -27,16 +32,16 @@ pub const kCFURLPOSIXPathStyle: CFURLPathStyle = 0;
2732
pub const kCFURLHFSPathStyle: CFURLPathStyle = 1;
2833
pub const kCFURLWindowsPathStyle: CFURLPathStyle = 2;
2934

30-
// static kCFURLBookmarkCreationPreferFileIDResolutionMask: CFURLBookmarkCreationOptions =
31-
// (1 << 8) as u32;
32-
// static kCFURLBookmarkCreationMinimalBookmarkMask: CFURLBookmarkCreationOptions =
33-
// (1 << 9) as u32;
34-
// static kCFURLBookmarkCreationSuitableForBookmarkFile: CFURLBookmarkCreationOptions =
35-
// (1 << 10) as u32;
36-
// static kCFURLBookmarkCreationWithSecurityScope: CFURLBookmarkCreationOptions =
37-
// (1 << 11) as u32;
38-
// static kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess: CFURLBookmarkCreationOptions =
39-
// (1 << 12) as u32;
35+
pub static kCFURLBookmarkCreationPreferFileIDResolutionMask: CFURLBookmarkCreationOptions =
36+
(1 << 8) as u32;
37+
pub static kCFURLBookmarkCreationMinimalBookmarkMask: CFURLBookmarkCreationOptions =
38+
(1 << 9) as u32;
39+
pub static kCFURLBookmarkCreationSuitableForBookmarkFile: CFURLBookmarkCreationOptions =
40+
(1 << 10) as u32;
41+
pub static kCFURLBookmarkCreationWithSecurityScope: CFURLBookmarkCreationOptions =
42+
(1 << 11) as u32;
43+
pub static kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess: CFURLBookmarkCreationOptions =
44+
(1 << 12) as u32;
4045

4146
// TODO: there are a lot of missing keys and constants. Add if you are bored or need them.
4247

@@ -83,8 +88,8 @@ extern {
8388

8489
/* Creating a CFURL */
8590
pub fn CFURLCopyAbsoluteURL(anURL: CFURLRef) -> CFURLRef;
86-
//fn CFURLCreateAbsoluteURLWithBytes
87-
//fn CFURLCreateByResolvingBookmarkData
91+
pub fn CFURLCreateAbsoluteURLWithBytes(allocator: CFAllocatorRef, relativeURLBytes: *const u8, length: CFIndex, encoding: CFStringEncoding, baseURL: CFURLRef, useCompatibilityMode: Boolean) -> CFURLRef;
92+
pub fn CFURLCreateByResolvingBookmarkData(allocator: CFAllocatorRef, bookmark: CFDataRef, options: CFURLBookmarkResolutionOptions, relativeToURL: CFURLRef, resourcePropertiesToInclude: CFArrayRef, isStale: *mut Boolean, error: *mut CFErrorRef) -> CFURLRef;
8893
//fn CFURLCreateCopyAppendingPathComponent
8994
//fn CFURLCreateCopyAppendingPathExtension
9095
//fn CFURLCreateCopyDeletingLastPathComponent
@@ -142,19 +147,19 @@ extern {
142147
//fn CFURLClearResourcePropertyCacheForKey
143148
//fn CFURLCopyResourcePropertiesForKeys
144149
//fn CFURLCopyResourcePropertyForKey
145-
//fn CFURLCreateResourcePropertiesForKeysFromBookmarkData
146-
//fn CFURLCreateResourcePropertyForKeyFromBookmarkData
150+
pub fn CFURLCreateResourcePropertiesForKeysFromBookmarkData(allocator: CFAllocatorRef, resourcePropertiesToReturn: CFArrayRef, bookmark: CFDataRef) -> CFDictionaryRef;
151+
pub fn CFURLCreateResourcePropertyForKeyFromBookmarkData(allocator: CFAllocatorRef, resourcePropertyKey: CFStringRef, bookmark: CFDataRef) -> CFTypeRef;
147152
//fn CFURLSetResourcePropertiesForKeys
148153
pub fn CFURLSetResourcePropertyForKey(url: CFURLRef, key: CFStringRef, value: CFTypeRef, error: *mut CFErrorRef) -> Boolean;
149154
//fn CFURLSetTemporaryResourcePropertyForKey
150155

151156
/* Working with Bookmark Data */
152-
//fn CFURLCreateBookmarkData
153-
//fn CFURLCreateBookmarkDataFromAliasRecord
154-
//fn CFURLCreateBookmarkDataFromFile
155-
//fn CFURLWriteBookmarkDataToFile
156-
//fn CFURLStartAccessingSecurityScopedResource
157-
//fn CFURLStopAccessingSecurityScopedResource
157+
pub fn CFURLCreateBookmarkData(allocator: CFAllocatorRef, url: CFURLRef, options: CFURLBookmarkCreationOptions, resourcePropertiesToInclude: CFArrayRef, relativeToURL: CFURLRef, error: *mut CFErrorRef) -> CFDataRef;
158+
pub fn CFURLCreateBookmarkDataFromAliasRecord(allocator: CFAllocatorRef, aliasRecordDataRef: CFDataRef) -> CFDataRef;
159+
pub fn CFURLCreateBookmarkDataFromFile(allocator: CFAllocatorRef, fileURL: CFURLRef, errorRef: *mut CFErrorRef) -> CFDataRef;
160+
pub fn CFURLWriteBookmarkDataToFile(bookmarkRef: CFDataRef, fileURL: CFURLRef, options: CFURLBookmarkFileCreationOptions, errorRef: *mut CFErrorRef) -> Boolean;
161+
pub fn CFURLStartAccessingSecurityScopedResource(url: CFURLRef) -> Boolean;
162+
pub fn CFURLStopAccessingSecurityScopedResource(url: CFURLRef);
158163
}
159164

160165
#[test]

0 commit comments

Comments
 (0)