2 * Copyright (c) 2011 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
25 Copyright (c) 1998-2011, Apple Inc. All rights reserved.
28 #if !defined(__COREFOUNDATION_CFURL__)
29 #define __COREFOUNDATION_CFURL__ 1
31 #include <CoreFoundation/CFBase.h>
32 #include <CoreFoundation/CFData.h>
33 #include <CoreFoundation/CFError.h>
34 #include <CoreFoundation/CFString.h>
35 #include <CoreFoundation/CFNumber.h>
40 kCFURLPOSIXPathStyle
= 0,
42 kCFURLWindowsPathStyle
44 typedef CFIndex CFURLPathStyle
;
46 typedef const struct __CFURL
* CFURLRef
;
48 /* CFURLs are composed of two fundamental pieces - their string, and a */
49 /* (possibly NULL) base URL. A relative URL is one in which the string */
50 /* by itself does not fully specify the URL (for instance "myDir/image.tiff"); */
51 /* an absolute URL is one in which the string does fully specify the URL */
52 /* ("file://localhost/myDir/image.tiff"). Absolute URLs always have NULL */
53 /* base URLs; however, it is possible for a URL to have a NULL base, and still */
54 /* not be absolute. Such a URL has only a relative string, and cannot be */
55 /* resolved. Two CFURLs are considered equal if and only if their strings */
56 /* are equal and their bases are equal. In other words, */
57 /* "file://localhost/myDir/image.tiff" is NOT equal to the URL with relative */
58 /* string "myDir/image.tiff" and base URL "file://localhost/". Clients that */
59 /* need these less strict form of equality should convert all URLs to their */
60 /* absolute form via CFURLCopyAbsoluteURL(), then compare the absolute forms. */
63 CFTypeID
CFURLGetTypeID(void);
65 /* encoding will be used both to interpret the bytes of URLBytes, and to */
66 /* interpret any percent-escapes within the bytes. */
68 CFURLRef
CFURLCreateWithBytes(CFAllocatorRef allocator
, const UInt8
*URLBytes
, CFIndex length
, CFStringEncoding encoding
, CFURLRef baseURL
);
70 /* Escapes any character that is not 7-bit ASCII with the byte-code */
71 /* for the given encoding. If escapeWhitespace is true, whitespace */
72 /* characters (' ', '\t', '\r', '\n') will be escaped also (desirable */
73 /* if embedding the URL into a larger text stream like HTML) */
75 CFDataRef
CFURLCreateData(CFAllocatorRef allocator
, CFURLRef url
, CFStringEncoding encoding
, Boolean escapeWhitespace
);
77 /* Any escape sequences in URLString will be interpreted via UTF-8. */
79 CFURLRef
CFURLCreateWithString(CFAllocatorRef allocator
, CFStringRef URLString
, CFURLRef baseURL
);
81 /* Create an absolute URL directly, without requiring the extra step */
82 /* of calling CFURLCopyAbsoluteURL(). If useCompatibilityMode is */
83 /* true, the rules historically used on the web are used to resolve */
84 /* relativeString against baseURL - these rules are generally listed */
85 /* in the RFC as optional or alternate interpretations. Otherwise, */
86 /* the strict rules from the RFC are used. The major differences are */
87 /* that in compatibility mode, we are lenient of the scheme appearing */
88 /* in relative portion, leading "../" components are removed from the */
89 /* final URL's path, and if the relative portion contains only */
90 /* resource specifier pieces (query, parameters, and fragment), then */
91 /* the last path component of the base URL will not be deleted */
93 CFURLRef
CFURLCreateAbsoluteURLWithBytes(CFAllocatorRef alloc
, const UInt8
*relativeURLBytes
, CFIndex length
, CFStringEncoding encoding
, CFURLRef baseURL
, Boolean useCompatibilityMode
);
95 /* filePath should be the URL's path expressed as a path of the type */
96 /* fsType. If filePath is not absolute, the resulting URL will be */
97 /* considered relative to the current working directory (evaluated */
98 /* at creation time). isDirectory determines whether filePath is */
99 /* treated as a directory path when resolving against relative path */
102 CFURLRef
CFURLCreateWithFileSystemPath(CFAllocatorRef allocator
, CFStringRef filePath
, CFURLPathStyle pathStyle
, Boolean isDirectory
);
105 CFURLRef
CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator
, const UInt8
*buffer
, CFIndex bufLen
, Boolean isDirectory
);
107 /* The path style of the baseURL must match the path style of the relative */
108 /* url or the results are undefined. If the provided filePath looks like an */
109 /* absolute path ( starting with '/' if pathStyle is kCFURLPosixPathStyle, */
110 /* not starting with ':' for kCFURLHFSPathStyle, or starting with what looks */
111 /* like a drive letter and colon for kCFURLWindowsPathStyle ) then the baseURL */
114 CFURLRef
CFURLCreateWithFileSystemPathRelativeToBase(CFAllocatorRef allocator
, CFStringRef filePath
, CFURLPathStyle pathStyle
, Boolean isDirectory
, CFURLRef baseURL
);
117 CFURLRef
CFURLCreateFromFileSystemRepresentationRelativeToBase(CFAllocatorRef allocator
, const UInt8
*buffer
, CFIndex bufLen
, Boolean isDirectory
, CFURLRef baseURL
);
119 /* Fills buffer with the file system's native representation of */
120 /* url's path. No more than maxBufLen bytes are written to buffer. */
121 /* The buffer should be at least the maximum path length for */
122 /* the file system in question to avoid failures for insufficiently */
123 /* large buffers. If resolveAgainstBase is true, the url's relative */
124 /* portion is resolved against its base before the path is computed. */
125 /* Returns success or failure. */
127 Boolean
CFURLGetFileSystemRepresentation(CFURLRef url
, Boolean resolveAgainstBase
, UInt8
*buffer
, CFIndex maxBufLen
);
129 /* Creates a new URL by resolving the relative portion of relativeURL against its base. */
131 CFURLRef
CFURLCopyAbsoluteURL(CFURLRef relativeURL
);
133 /* Returns the URL's string. */
135 CFStringRef
CFURLGetString(CFURLRef anURL
);
137 /* Returns the base URL if it exists */
139 CFURLRef
CFURLGetBaseURL(CFURLRef anURL
);
142 All URLs can be broken into two pieces - the scheme (preceding the
143 first colon) and the resource specifier (following the first colon).
144 Most URLs are also "standard" URLs conforming to RFC 1808 (available
145 from www.w3c.org). This category includes URLs of the file, http,
146 https, and ftp schemes, to name a few. Standard URLs start the
147 resource specifier with two slashes ("//"), and can be broken into
148 four distinct pieces - the scheme, the net location, the path, and
149 further resource specifiers (typically an optional parameter, query,
150 and/or fragment). The net location appears immediately following
151 the two slashes and goes up to the next slash; it's format is
152 scheme-specific, but is usually composed of some or all of a username,
153 password, host name, and port. The path is a series of path components
154 separated by slashes; if the net location is present, the path always
155 begins with a slash. Standard URLs can be relative to another URL,
156 in which case at least the scheme and possibly other pieces as well
157 come from the base URL (see RFC 1808 for precise details when resolving
158 a relative URL against its base). The full URL is therefore
160 <scheme> "://" <net location> <path, always starting with slash> <add'l resource specifiers>
162 If a given CFURL can be decomposed (that is, conforms to RFC 1808), you
163 can ask for each of the four basic pieces (scheme, net location, path,
164 and resource specifer) separately, as well as for its base URL. The
165 basic pieces are returned with any percent escape sequences still in
166 place (although note that the scheme may not legally include any
167 percent escapes); this is to allow the caller to distinguish between
168 percent sequences that may have syntactic meaning if replaced by the
169 character being escaped (for instance, a '/' in a path component).
170 Since only the individual schemes know which characters are
171 syntactically significant, CFURL cannot safely replace any percent
172 escape sequences. However, you can use
173 CFURLCreateStringByReplacingPercentEscapes() to create a new string with
174 the percent escapes removed; see below.
176 If a given CFURL can not be decomposed, you can ask for its scheme and its
177 resource specifier; asking it for its net location or path will return NULL.
179 To get more refined information about the components of a decomposable
180 CFURL, you may ask for more specific pieces of the URL, expressed with
181 the percent escapes removed. The available functions are CFURLCopyHostName(),
182 CFURLGetPortNumber() (returns an Int32), CFURLCopyUserName(),
183 CFURLCopyPassword(), CFURLCopyQuery(), CFURLCopyParameters(), and
184 CFURLCopyFragment(). Because the parameters, query, and fragment of an
185 URL may contain scheme-specific syntaxes, these methods take a second
186 argument, giving a list of characters which should NOT be replaced if
187 percent escaped. For instance, the ftp parameter syntax gives simple
188 key-value pairs as "<key>=<value>;" Clearly if a key or value includes
189 either '=' or ';', it must be escaped to avoid corrupting the meaning of
190 the parameters, so the caller may request the parameter string as
192 CFStringRef myParams = CFURLCopyParameters(ftpURL, CFSTR("=;%"));
194 requesting that all percent escape sequences be replaced by the represented
195 characters, except for escaped '=', '%' or ';' characters. Pass the empty
196 string (CFSTR("")) to request that all percent escapes be replaced, or NULL
197 to request that none be.
200 /* Returns true if anURL conforms to RFC 1808 */
202 Boolean
CFURLCanBeDecomposed(CFURLRef anURL
);
204 /* The next several methods leave any percent escape sequences intact */
207 CFStringRef
CFURLCopyScheme(CFURLRef anURL
);
209 /* NULL if CFURLCanBeDecomposed(anURL) is false */
211 CFStringRef
CFURLCopyNetLocation(CFURLRef anURL
);
213 /* NULL if CFURLCanBeDecomposed(anURL) is false; also does not resolve the URL */
214 /* against its base. See also CFURLCopyAbsoluteURL(). Note that, strictly */
215 /* speaking, any leading '/' is not considered part of the URL's path, although */
216 /* its presence or absence determines whether the path is absolute. */
217 /* CFURLCopyPath()'s return value includes any leading slash (giving the path */
218 /* the normal POSIX appearance); CFURLCopyStrictPath()'s return value omits any */
219 /* leading slash, and uses isAbsolute to report whether the URL's path is absolute. */
221 /* CFURLCopyFileSystemPath() returns the URL's path as a file system path for the */
222 /* given path style. All percent escape sequences are replaced. The URL is not */
223 /* resolved against its base before computing the path. */
225 CFStringRef
CFURLCopyPath(CFURLRef anURL
);
228 CFStringRef
CFURLCopyStrictPath(CFURLRef anURL
, Boolean
*isAbsolute
);
231 CFStringRef
CFURLCopyFileSystemPath(CFURLRef anURL
, CFURLPathStyle pathStyle
);
233 /* Returns whether anURL's path represents a directory */
234 /* (true returned) or a simple file (false returned) */
236 Boolean
CFURLHasDirectoryPath(CFURLRef anURL
);
238 /* Any additional resource specifiers after the path. For URLs */
239 /* that cannot be decomposed, this is everything except the scheme itself. */
241 CFStringRef
CFURLCopyResourceSpecifier(CFURLRef anURL
);
244 CFStringRef
CFURLCopyHostName(CFURLRef anURL
);
247 SInt32
CFURLGetPortNumber(CFURLRef anURL
); /* Returns -1 if no port number is specified */
250 CFStringRef
CFURLCopyUserName(CFURLRef anURL
);
253 CFStringRef
CFURLCopyPassword(CFURLRef anURL
);
255 /* These remove all percent escape sequences except those for */
256 /* characters in charactersToLeaveEscaped. If charactersToLeaveEscaped */
257 /* is empty (""), all percent escape sequences are replaced by their */
258 /* corresponding characters. If charactersToLeaveEscaped is NULL, */
259 /* then no escape sequences are removed at all */
261 CFStringRef
CFURLCopyParameterString(CFURLRef anURL
, CFStringRef charactersToLeaveEscaped
);
264 CFStringRef
CFURLCopyQueryString(CFURLRef anURL
, CFStringRef charactersToLeaveEscaped
);
267 CFStringRef
CFURLCopyFragment(CFURLRef anURL
, CFStringRef charactersToLeaveEscaped
);
270 CFStringRef
CFURLCopyLastPathComponent(CFURLRef url
);
273 CFStringRef
CFURLCopyPathExtension(CFURLRef url
);
275 /* These functions all treat the base URL of the supplied url as */
276 /* invariant. In other words, the URL returned will always have */
277 /* the same base as the URL supplied as an argument. */
280 CFURLRef
CFURLCreateCopyAppendingPathComponent(CFAllocatorRef allocator
, CFURLRef url
, CFStringRef pathComponent
, Boolean isDirectory
);
283 CFURLRef
CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator
, CFURLRef url
);
286 CFURLRef
CFURLCreateCopyAppendingPathExtension(CFAllocatorRef allocator
, CFURLRef url
, CFStringRef extension
);
289 CFURLRef
CFURLCreateCopyDeletingPathExtension(CFAllocatorRef allocator
, CFURLRef url
);
291 /* Fills buffer with the bytes for url, returning the number of bytes */
292 /* filled. If buffer is of insufficient size, returns -1 and no bytes */
293 /* are placed in buffer. If buffer is NULL, the needed length is */
294 /* computed and returned. The returned bytes are the original bytes */
295 /* from which the URL was created; if the URL was created from a */
296 /* string, the bytes will be the bytes of the string encoded via UTF-8 */
298 CFIndex
CFURLGetBytes(CFURLRef url
, UInt8
*buffer
, CFIndex bufferLength
);
301 kCFURLComponentScheme
= 1,
302 kCFURLComponentNetLocation
= 2,
303 kCFURLComponentPath
= 3,
304 kCFURLComponentResourceSpecifier
= 4,
306 kCFURLComponentUser
= 5,
307 kCFURLComponentPassword
= 6,
308 kCFURLComponentUserInfo
= 7,
309 kCFURLComponentHost
= 8,
310 kCFURLComponentPort
= 9,
311 kCFURLComponentParameterString
= 10,
312 kCFURLComponentQuery
= 11,
313 kCFURLComponentFragment
= 12
315 typedef CFIndex CFURLComponentType
;
318 Gets the range of the requested component in the bytes of url, as
319 returned by CFURLGetBytes(). This range is only good for use in the
320 bytes returned by CFURLGetBytes!
322 If non-NULL, rangeIncludingSeparators gives the range of component
323 including the sequences that separate component from the previous and
324 next components. If there is no previous or next component, that end of
325 rangeIncludingSeparators will match the range of the component itself.
326 If url does not contain the given component type, (kCFNotFound, 0) is
327 returned, and rangeIncludingSeparators is set to the location where the
328 component would be inserted. Some examples -
330 For the URL http://www.apple.com/hotnews/
332 Component returned range rangeIncludingSeparators
334 net location (7, 13) (4, 16)
336 resource specifier (kCFNotFound, 0) (29, 0)
337 user (kCFNotFound, 0) (7, 0)
338 password (kCFNotFound, 0) (7, 0)
339 user info (kCFNotFound, 0) (7, 0)
341 port (kCFNotFound, 0) (20, 0)
342 parameter (kCFNotFound, 0) (29, 0)
343 query (kCFNotFound, 0) (29, 0)
344 fragment (kCFNotFound, 0) (29, 0)
347 For the URL ./relPath/file.html#fragment
349 Component returned range rangeIncludingSeparators
350 scheme (kCFNotFound, 0) (0, 0)
351 net location (kCFNotFound, 0) (0, 0)
353 resource specifier (20, 8) (19, 9)
354 user (kCFNotFound, 0) (0, 0)
355 password (kCFNotFound, 0) (0, 0)
356 user info (kCFNotFound, 0) (0, 0)
357 host (kCFNotFound, 0) (0, 0)
358 port (kCFNotFound, 0) (0, 0)
359 parameter (kCFNotFound, 0) (19, 0)
360 query (kCFNotFound, 0) (19, 0)
361 fragment (20, 8) (19, 9)
364 For the URL scheme://user:pass@host:1/path/path2/file.html;params?query#fragment
366 Component returned range rangeIncludingSeparators
368 net location (9, 16) (6, 19)
369 path (25, 21) (25, 22)
370 resource specifier (47, 21) (46, 22)
372 password (14, 4) (13, 6)
373 user info (9, 9) (6, 13)
376 parameter (47, 6) (46, 8)
377 query (54, 5) (53, 7)
378 fragment (60, 8) (59, 9)
381 CFRange
CFURLGetByteRangeForComponent(CFURLRef url
, CFURLComponentType component
, CFRange
*rangeIncludingSeparators
);
383 /* Returns a string with any percent escape sequences that do NOT */
384 /* correspond to characters in charactersToLeaveEscaped with their */
385 /* equivalent. Returns NULL on failure (if an invalid percent sequence */
386 /* is encountered), or the original string (retained) if no characters */
387 /* need to be replaced. Pass NULL to request that no percent escapes be */
388 /* replaced, or the empty string (CFSTR("")) to request that all percent */
389 /* escapes be replaced. Uses UTF8 to interpret percent escapes. */
391 CFStringRef
CFURLCreateStringByReplacingPercentEscapes(CFAllocatorRef allocator
, CFStringRef originalString
, CFStringRef charactersToLeaveEscaped
);
393 /* As above, but allows you to specify the encoding to use when interpreting percent escapes */
395 CFStringRef
CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFAllocatorRef allocator
, CFStringRef origString
, CFStringRef charsToLeaveEscaped
, CFStringEncoding encoding
);
397 /* Creates a copy or originalString, replacing certain characters with */
398 /* the equivalent percent escape sequence based on the encoding specified. */
399 /* If the originalString does not need to be modified (no percent escape */
400 /* sequences are missing), may retain and return originalString. */
401 /* If you are uncertain of the correct encoding, you should use UTF-8, */
402 /* which is the encoding designated by RFC 2396 as the correct encoding */
403 /* for use in URLs. The characters so escaped are all characters that */
404 /* are not legal URL characters (based on RFC 2396), plus any characters */
405 /* in legalURLCharactersToBeEscaped, less any characters in */
406 /* charactersToLeaveUnescaped. To simply correct any non-URL characters */
407 /* in an otherwise correct URL string, do: */
409 /* newString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, origString, NULL, NULL, kCFStringEncodingUTF8); */
411 CFStringRef
CFURLCreateStringByAddingPercentEscapes(CFAllocatorRef allocator
, CFStringRef originalString
, CFStringRef charactersToLeaveUnescaped
, CFStringRef legalURLCharactersToBeEscaped
, CFStringEncoding encoding
);
414 #if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION
416 /* Returns a file reference URL, a path-idependent form of file URL. */
417 /* Converts a file path URL if necessary. For non-file URLs, returns NULL. */
418 /* Also returns NULL when the conversion fails because the target resource doesn't exist. */
419 /* Optional output error: The error is set to a valid CFErrorRef when the function */
420 /* result is NULL. A valid output error must be released by the caller. */
422 CFURLRef
CFURLCreateFileReferenceURL(CFAllocatorRef allocator
, CFURLRef url
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
425 /* Returns a file path URL, converting a file reference URL if necessary. */
426 /* For non-file URLs, returns NULL. Also returns NULL when the conversion fails */
427 /* because the target resource doesn't exist. */
428 /* Optional output error: The error is set to a valid CFErrorRef when the function */
429 /* result is NULL. A valid output error must be released by the caller. */
431 CFURLRef
CFURLCreateFilePathURL(CFAllocatorRef allocator
, CFURLRef url
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
437 #if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION
439 /* The following APIs provide efficient access to resource properties. Properties
440 are identified by keys, and values are represented as Core Foundation objects. The
441 type of each value is fixed for each property, e.g. the modification date is a CFDateRef,
442 the file size is a CFNumberRef.
444 Values are fetched on-demand, synchronously, from the resource's backing store. They
445 are cached and reused when fetched again through the same URL instance, until the
446 client clears the value. The client has complete control over the cache lifetime.
448 Some resource property values can be changed, given sufficient access permission to the resource.
449 When a resource property value is set, the change is written to backing store synchronously.
452 /* Assigns the requested resource property value to the typeRefValuePtr output */
453 /* argument. Returns true if the output value was set. Note that NULL is a valid output value. */
454 /* The value is fetched synchronously from the resource backing store only if a value is not */
455 /* already cached. The type of the output value type varies by property (see property key */
456 /* definitions). Returns false if an error occurs. Optional output error: the error is set to */
457 /* a valid CFErrorRef when the function returns false. A valid output error must be */
458 /* released by the caller. */
460 Boolean
CFURLCopyResourcePropertyForKey(CFURLRef url
, CFStringRef key
, void *propertyValueTypeRefPtr
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
463 /* Returns any number of resource property values as a dictionary of keyed values. */
464 /* The requested values are specified as an array of keys to appear in */
465 /* the result dictionary. Values are fetched synchronously from the resource backing store unless */
466 /* already cached. The type of each value type varies (see key definitions, below). */
467 /* Returns an empty dictionary if no values are found. Returns NULL when an error occurs. */
468 /* Optional output error: the error is set to a valid CFErrorRef when the */
469 /* function returns NULL. A valid output error must be released by the caller. */
471 CFDictionaryRef
CFURLCopyResourcePropertiesForKeys(CFURLRef url
, CFArrayRef keys
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
474 /* Changes a resource property value. Synchronously writes the value to the resource backing */
475 /* store. The input value type must be a valid CFTypeRef, of the type required for the specified */
476 /* key (see key definitions). Returns true upon success, false when an error occurs. */
477 /* Optional output error: the error is set to a valid CFErrorRef when the function */
478 /* returns false. A valid output error must be released by the caller. */
479 /* Note that some values are read-only. Attempting to set a read-only property */
480 /* results in an error. */
482 Boolean
CFURLSetResourcePropertyForKey(CFURLRef url
, CFStringRef key
, CFTypeRef propertyValue
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
485 /* Changes any number of resource property values, specified as a dictionary of keyed values. */
486 /* Synchronously writes values to the resource backing store. The input dictionary's value types must conform */
487 /* to the type required for its key (see key definitions). Returns true when all values are set successfully, */
488 /* and false if an error occurs. Optional output error: the error is set to a valid CFErrorRef when the function returns */
489 /* false. A valid output error must be released by the caller. When an error occurs after some properties have been */
490 /* successfully changed, the userInfo dictionary in the error contains an array of keys that */
491 /* were not set with the dictionary key kCFURLKeysOfUnsetValuesKey. */
492 /* Note that some values are read-only. Attempting to set a read-only value results in an error. */
494 Boolean
CFURLSetResourcePropertiesForKeys(CFURLRef url
, CFDictionaryRef keyedPropertyValues
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
498 const CFStringRef kCFURLKeysOfUnsetValuesKey
CF_AVAILABLE(10_7
, 5_0
);
499 /* If CFURLSetResourcePropertiesForKeys returns an error, this is key in the error's userInfo dictionary to the array of keys of unset values. */
502 /* Discards a cached property value for a specific key */
504 void CFURLClearResourcePropertyCacheForKey(CFURLRef url
, CFStringRef key
) CF_AVAILABLE(10_6
, 4_0
);
507 /* Discards all cached property values */
509 void CFURLClearResourcePropertyCache(CFURLRef url
) CF_AVAILABLE(10_6
, 4_0
);
512 /* Sets a temporary property value. Temporary properties exist only in memory and are never */
513 /* written to resource backing store. Once set, a temporary property value can be fetched */
514 /* with CFURLCopyResourcePropertyForKey and CFURLCopyResourcePropertiesForKeys. Temporary property */
515 /* values are for client use. Values must be valid Core Foundation types, and will be retained. */
516 /* To remove a temporary property value, use CFURLClearResourcePropertyCacheForKey. */
518 void CFURLSetTemporaryResourcePropertyForKey(CFURLRef url
, CFStringRef key
, CFTypeRef propertyValue
) CF_AVAILABLE(10_6
, 4_0
);
521 /* Synchronously checks if the resource's backing store is reachable and the resource exists, */
522 /* returning true if so. The optional output error can be used to determine the type of reachability */
523 /* failure (e.g., file not found, network error, etc.). The error is set to a valid CFErrorRef if */
524 /* and only if the function returns false. A valid output error must be released by */
525 /* the caller. Checking for resource existence and reachability is appropriate when making decisions */
526 /* that do not require other immediate operations on the resource. An example would be */
527 /* periodic maintenance of UI state that depends on the existence of a particular document. */
528 /* When performing an operation such as opening a file, it is more efficient to */
529 /* simply try the operation and handle failures than to check first for reachability. */
531 Boolean
CFURLResourceIsReachable(CFURLRef url
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
534 /* Properties of File System Resources */
537 const CFStringRef kCFURLNameKey
CF_AVAILABLE(10_6
, 4_0
);
538 /* The resource name provided by the file system (value type CFString) */
541 const CFStringRef kCFURLLocalizedNameKey
CF_AVAILABLE(10_6
, 4_0
);
542 /* Localized or extension-hidden name as displayed to users (Read-only, value type CFString) */
545 const CFStringRef kCFURLIsRegularFileKey
CF_AVAILABLE(10_6
, 4_0
);
546 /* True for regular files (Read-only, value type CFBoolean) */
549 const CFStringRef kCFURLIsDirectoryKey
CF_AVAILABLE(10_6
, 4_0
);
550 /* True for directories (Read-only, CFBoolean) */
553 const CFStringRef kCFURLIsSymbolicLinkKey
CF_AVAILABLE(10_6
, 4_0
);
554 /* True for symlinks (Read-only, value type CFBoolean) */
557 const CFStringRef kCFURLIsVolumeKey
CF_AVAILABLE(10_6
, 4_0
);
558 /* True for the root directory of a volume (Read-only, value type CFBoolean) */
561 const CFStringRef kCFURLIsPackageKey
CF_AVAILABLE(10_6
, 4_0
);
562 /* True for packaged directories (value type CFBoolean) */
565 const CFStringRef kCFURLIsSystemImmutableKey
CF_AVAILABLE(10_6
, 4_0
);
566 /* True for system-immutable resources (value type CFBoolean) */
569 const CFStringRef kCFURLIsUserImmutableKey
CF_AVAILABLE(10_6
, 4_0
);
570 /* True for user-immutable resources (value type CFBoolean) */
573 const CFStringRef kCFURLIsHiddenKey
CF_AVAILABLE(10_6
, 4_0
);
574 /* True for resources normally hidden from users (value type CFBoolean) */
577 const CFStringRef kCFURLHasHiddenExtensionKey
CF_AVAILABLE(10_6
, 4_0
);
578 /* True for resources whose filename extension is hidden (value type CFBoolean) */
581 const CFStringRef kCFURLCreationDateKey
CF_AVAILABLE(10_6
, 4_0
);
582 /* The date the resource was created (value type CFDate) */
585 const CFStringRef kCFURLContentAccessDateKey
CF_AVAILABLE(10_6
, 4_0
);
586 /* The date the resource was last accessed (Read-only, value type CFDate) */
589 const CFStringRef kCFURLContentModificationDateKey
CF_AVAILABLE(10_6
, 4_0
);
590 /* The time the resource content was last modified (value type CFDate) */
593 const CFStringRef kCFURLAttributeModificationDateKey
CF_AVAILABLE(10_6
, 4_0
);
594 /* The time the resource's attributes were last modified (value type CFDate) */
597 const CFStringRef kCFURLLinkCountKey
CF_AVAILABLE(10_6
, 4_0
);
598 /* Number of hard links to the resource (Read-only, CFNumber) */
601 const CFStringRef kCFURLParentDirectoryURLKey
CF_AVAILABLE(10_6
, 4_0
);
602 /* URL of the parent directory, if any (Read-only, value type CFURL) */
605 const CFStringRef kCFURLVolumeURLKey
CF_AVAILABLE(10_6
, 4_0
);
606 /* URL of the volume on which the resource is stored (Read-only, value type CFURL) */
609 const CFStringRef kCFURLTypeIdentifierKey
CF_AVAILABLE(10_6
, 4_0
);
610 /* Uniform type identifier for the resource (Read-only, value type CFString) */
613 const CFStringRef kCFURLLocalizedTypeDescriptionKey
CF_AVAILABLE(10_6
, 4_0
);
614 /* User-visible type or "kind" descriptiopn (Read-only, value type CFString) */
617 const CFStringRef kCFURLLabelNumberKey
CF_AVAILABLE(10_6
, 4_0
);
618 /* The label number assigned to the resource (value type CFNumber) */
621 const CFStringRef kCFURLLabelColorKey
CF_AVAILABLE(10_6
, 4_0
);
622 /* The color of the assigned label (Read-only, value type CGColorRef, must link with Application Services) */
625 const CFStringRef kCFURLLocalizedLabelKey
CF_AVAILABLE(10_6
, 4_0
);
626 /* The user-visible label text (Read-only, value type CFString) */
629 const CFStringRef kCFURLEffectiveIconKey
CF_AVAILABLE(10_6
, 4_0
);
630 /* The icon normally displayed for the resource (Read-only, value type CGImageRef, must link with Application Services) */
633 const CFStringRef kCFURLCustomIconKey
CF_AVAILABLE(10_6
, 4_0
);
634 /* The custom icon assigned to the resource, if any (value type CGImageRef, must link with Application Services) */
637 const CFStringRef kCFURLFileResourceIdentifierKey
CF_AVAILABLE(10_7
, 5_0
);
638 /* An identifier which can be used to compare two file system objects for equality using CFEqual (i.e, two object identifiers are equal if they have the same file system path or if the paths are linked to same inode on the same file system). This identifier is not persistent across system restarts. (Read-only, value type CFType) */
641 const CFStringRef kCFURLVolumeIdentifierKey
CF_AVAILABLE(10_7
, 5_0
);
642 /* An identifier that can be used to identify the volume the file system object is on. Other objects on the same volume will have the same volume identifier and can be compared using for equality using CFEqual. This identifier is not persistent across system restarts. (Read-only, value type CFType) */
645 const CFStringRef kCFURLPreferredIOBlockSizeKey
CF_AVAILABLE(10_7
, 5_0
);
646 /* The optimal block size when reading or writing this file's data, or NULL if not available. (Read-only, value type CFNumber) */
649 const CFStringRef kCFURLIsReadableKey
CF_AVAILABLE(10_7
, 5_0
);
650 /* true if this process (as determined by EUID) can read the resource. (Read-only, value type CFBoolean) */
653 const CFStringRef kCFURLIsWritableKey
CF_AVAILABLE(10_7
, 5_0
);
654 /* true if this process (as determined by EUID) can write to the resource. (Read-only, value type CFBoolean) */
657 const CFStringRef kCFURLIsExecutableKey
CF_AVAILABLE(10_7
, 5_0
);
658 /* true if this process (as determined by EUID) can execute a file resource or search a directory resource. (Read-only, value type CFBoolean) */
661 const CFStringRef kCFURLFileSecurityKey
CF_AVAILABLE(10_7
, 5_0
);
662 /* The file system object's security information encapsulated in a CFFileSecurity object. (Value type CFFileSecurity) */
665 const CFStringRef kCFURLFileResourceTypeKey
CF_AVAILABLE(10_7
, 5_0
);
666 /* Returns the file system object type. (Read-only, value type CFString) */
668 /* The file system object type values returned for the kCFURLFileResourceTypeKey */
670 const CFStringRef kCFURLFileResourceTypeNamedPipe
CF_AVAILABLE(10_7
, 5_0
);
672 const CFStringRef kCFURLFileResourceTypeCharacterSpecial
CF_AVAILABLE(10_7
, 5_0
);
674 const CFStringRef kCFURLFileResourceTypeDirectory
CF_AVAILABLE(10_7
, 5_0
);
676 const CFStringRef kCFURLFileResourceTypeBlockSpecial
CF_AVAILABLE(10_7
, 5_0
);
678 const CFStringRef kCFURLFileResourceTypeRegular
CF_AVAILABLE(10_7
, 5_0
);
680 const CFStringRef kCFURLFileResourceTypeSymbolicLink
CF_AVAILABLE(10_7
, 5_0
);
682 const CFStringRef kCFURLFileResourceTypeSocket
CF_AVAILABLE(10_7
, 5_0
);
684 const CFStringRef kCFURLFileResourceTypeUnknown
CF_AVAILABLE(10_7
, 5_0
);
686 /* File Properties */
689 const CFStringRef kCFURLFileSizeKey
CF_AVAILABLE(10_6
, 4_0
);
690 /* Total file size, in bytes (Read-only, value type CFNumber) */
693 const CFStringRef kCFURLFileAllocatedSizeKey
CF_AVAILABLE(10_6
, 4_0
);
694 /* Total size of blocks allocated (Read-only, value type CFNumber) */
697 const CFStringRef kCFURLTotalFileSizeKey
CF_AVAILABLE(10_7
, 5_0
);
698 /* Total displayable size of the file, in bytes (this may include space used by metadata), or NULL if not available. (Read-only, value type CFNumber) */
701 const CFStringRef kCFURLTotalFileAllocatedSizeKey
CF_AVAILABLE(10_7
, 5_0
);
702 /* Total allocated size of the file, in bytes (this may include space used by metadata), or NULL if not available. This can be less than the value returned by kCFURLTotalFileSizeKey if the resource is compressed. (Read-only, value type CFNumber) */
705 const CFStringRef kCFURLIsAliasFileKey
CF_AVAILABLE(10_6
, 4_0
);
706 /* true if the url is a Finder alias file, false otherwise ( Read-only, value type CFBooleanRef) */
709 const CFStringRef kCFURLIsMountTriggerKey
CF_AVAILABLE(10_7
, 4_0
);
710 /* true if this URL is a file system trigger directory. Traversing or opening a file system trigger will cause an attempt to mount a file system on the trigger directory. (Read-only, value type CFBoolean) */
713 /* Volume Properties */
715 /* For convenience, volume properties may be requested from any resource on a volume. */
718 const CFStringRef kCFURLVolumeLocalizedFormatDescriptionKey
CF_AVAILABLE(10_6
, 4_0
);
719 /* The user-visible volume format (Read-only, value type CFString) */
722 const CFStringRef kCFURLVolumeTotalCapacityKey
CF_AVAILABLE(10_6
, 4_0
);
723 /* Total volume capacity in bytes (Read-only, value type CFNumber) */
726 const CFStringRef kCFURLVolumeAvailableCapacityKey
CF_AVAILABLE(10_6
, 4_0
);
727 /* Total free space, in bytes (Read-only, value type CFNumber) */
730 const CFStringRef kCFURLVolumeResourceCountKey
CF_AVAILABLE(10_6
, 4_0
);
731 /* Total number of resources on the volume (Read-only, value type CFNumber) */
734 const CFStringRef kCFURLVolumeSupportsPersistentIDsKey
CF_AVAILABLE(10_6
, 4_0
);
735 /* Read-only, value type CFBoolean */
738 const CFStringRef kCFURLVolumeSupportsSymbolicLinksKey
CF_AVAILABLE(10_6
, 4_0
);
739 /* Read-only, value type CFBoolean */
742 const CFStringRef kCFURLVolumeSupportsHardLinksKey
CF_AVAILABLE(10_6
, 4_0
);
743 /* Read-only, value type CFBoolean */
746 const CFStringRef kCFURLVolumeSupportsJournalingKey
CF_AVAILABLE(10_6
, 4_0
);
747 /* Read-only, value type CFBoolean */
750 const CFStringRef kCFURLVolumeIsJournalingKey
CF_AVAILABLE(10_6
, 4_0
);
751 /* Read-only, value type CFBoolean */
754 const CFStringRef kCFURLVolumeSupportsSparseFilesKey
CF_AVAILABLE(10_6
, 4_0
);
755 /* Read-only, value type CFBoolean */
758 const CFStringRef kCFURLVolumeSupportsZeroRunsKey
CF_AVAILABLE(10_6
, 4_0
);
759 /* Read-only, value type CFBoolean */
762 const CFStringRef kCFURLVolumeSupportsCaseSensitiveNamesKey
CF_AVAILABLE(10_6
, 4_0
);
763 /* Read-only, value type CFBoolean */
766 const CFStringRef kCFURLVolumeSupportsCasePreservedNamesKey
CF_AVAILABLE(10_6
, 4_0
);
767 /* Read-only, value type CFBoolean */
770 const CFStringRef kCFURLVolumeSupportsRootDirectoryDatesKey
CF_AVAILABLE(10_7
, 5_0
);
771 /* true if the volume supports reliable storage of times for the root directory. (Read-only, value type CFBoolean) */
774 const CFStringRef kCFURLVolumeSupportsVolumeSizesKey
CF_AVAILABLE(10_7
, 5_0
);
775 /* true if the volume supports returning volume size values (kCFURLVolumeTotalCapacityKey and kCFURLVolumeAvailableCapacityKey). (Read-only, value type CFBoolean) */
778 const CFStringRef kCFURLVolumeSupportsRenamingKey
CF_AVAILABLE(10_7
, 5_0
);
779 /* true if the volume can be renamed. (Read-only, value type CFBoolean) */
782 const CFStringRef kCFURLVolumeSupportsAdvisoryFileLockingKey
CF_AVAILABLE(10_7
, 5_0
);
783 /* true if the volume implements whole-file flock(2) style advisory locks, and the O_EXLOCK and O_SHLOCK flags of the open(2) call. (Read-only, value type CFBoolean) */
786 const CFStringRef kCFURLVolumeSupportsExtendedSecurityKey
CF_AVAILABLE(10_7
, 5_0
);
787 /* true if the volume implements extended security (ACLs). (Read-only, value type CFBoolean) */
790 const CFStringRef kCFURLVolumeIsBrowsableKey
CF_AVAILABLE(10_7
, 5_0
);
791 /* true if the volume should be visible via the GUI (i.e., appear on the Desktop as a separate volume). (Read-only, value type CFBoolean) */
794 const CFStringRef kCFURLVolumeMaximumFileSizeKey
CF_AVAILABLE(10_7
, 5_0
);
795 /* The largest file size (in bytes) supported by this file system, or NULL if this cannot be determined. (Read-only, value type CFNumber) */
798 const CFStringRef kCFURLVolumeIsEjectableKey
CF_AVAILABLE(10_7
, 5_0
);
799 /* true if the volume's media is ejectable from the drive mechanism under software control. (Read-only, value type CFBoolean) */
802 const CFStringRef kCFURLVolumeIsRemovableKey
CF_AVAILABLE(10_7
, 5_0
);
803 /* true if the volume's media is removable from the drive mechanism. (Read-only, value type CFBoolean) */
806 const CFStringRef kCFURLVolumeIsInternalKey
CF_AVAILABLE(10_7
, 5_0
);
807 /* true if the volume's device is connected to an internal bus, false if connected to an external bus, or NULL if not available. (Read-only, value type CFBoolean) */
810 const CFStringRef kCFURLVolumeIsAutomountedKey
CF_AVAILABLE(10_7
, 5_0
);
811 /* true if the volume is automounted. Note: do not mistake this with the functionality provided by kCFURLVolumeSupportsBrowsingKey. (Read-only, value type CFBoolean) */
814 const CFStringRef kCFURLVolumeIsLocalKey
CF_AVAILABLE(10_7
, 5_0
);
815 /* true if the volume is stored on a local device. (Read-only, value type CFBoolean) */
818 const CFStringRef kCFURLVolumeIsReadOnlyKey
CF_AVAILABLE(10_7
, 5_0
);
819 /* true if the volume is read-only. (Read-only, value type CFBoolean) */
822 const CFStringRef kCFURLVolumeCreationDateKey
CF_AVAILABLE(10_7
, 5_0
);
823 /* The volume's creation date, or NULL if this cannot be determined. (Read-only, value type CFDate) */
826 const CFStringRef kCFURLVolumeURLForRemountingKey
CF_AVAILABLE(10_7
, 5_0
);
827 /* The CFURL needed to remount a network volume, or NULL if not available. (Read-only, value type CFURL) */
830 const CFStringRef kCFURLVolumeUUIDStringKey
CF_AVAILABLE(10_7
, 5_0
);
831 /* The volume's persistent UUID as a string, or NULL if a persistent UUID is not available for the volume. (Read-only, value type CFString) */
834 const CFStringRef kCFURLVolumeNameKey
CF_AVAILABLE(10_7
, 5_0
);
835 /* The name of the volume (settable if kCFURLVolumeSupportsRenamingKey is true, value type CFString) */
838 const CFStringRef kCFURLVolumeLocalizedNameKey
CF_AVAILABLE(10_7
, 5_0
);
839 /* The user-presentable name of the volume (Read-only, value type CFString) */
841 /* UbiquitousItem Properties */
844 const CFStringRef kCFURLIsUbiquitousItemKey
CF_AVAILABLE(10_7
, 5_0
);
845 /* true if this item is synced to the cloud, false if it is only a local file. (Read-only, value type CFBoolean) */
848 const CFStringRef kCFURLUbiquitousItemHasUnresolvedConflictsKey
CF_AVAILABLE(10_7
, 5_0
);
849 /* true if this item has conflicts outstanding. (Read-only, value type CFBoolean) */
852 const CFStringRef kCFURLUbiquitousItemIsDownloadedKey
CF_AVAILABLE(10_7
, 5_0
);
853 /* true if there is local data present for this item. (Read-only, value type CFBoolean) */
856 const CFStringRef kCFURLUbiquitousItemIsDownloadingKey
CF_AVAILABLE(10_7
, 5_0
);
857 /* true if data is being downloaded for this item. (Read-only, value type CFBoolean) */
860 const CFStringRef kCFURLUbiquitousItemIsUploadedKey
CF_AVAILABLE(10_7
, 5_0
);
861 /* true if there is data present in the cloud for this item. (Read-only, value type CFBoolean) */
864 const CFStringRef kCFURLUbiquitousItemIsUploadingKey
CF_AVAILABLE(10_7
, 5_0
);
865 /* true if data is being uploaded for this item. (Read-only, value type CFBoolean) */
868 const CFStringRef kCFURLUbiquitousItemPercentDownloadedKey
CF_AVAILABLE(10_7
, 5_0
);
869 /* [0-100] percent of data downloaded. (Read-only, value type double CFNumber) */
872 const CFStringRef kCFURLUbiquitousItemPercentUploadedKey
CF_AVAILABLE(10_7
, 5_0
);
873 /* [0-100] percent of data downloaded. (Read-only, value type double CFNumber) */
876 kCFURLBookmarkCreationPreferFileIDResolutionMask
= ( 1UL << 8 ), // At resolution time, this alias will prefer resolving by the embedded fileID to the path
877 kCFURLBookmarkCreationMinimalBookmarkMask
= ( 1UL << 9 ), // Creates a bookmark with "less" information, which may be smaller but still be able to resolve in certain ways
878 kCFURLBookmarkCreationSuitableForBookmarkFile
= ( 1UL << 10 ), // includes in the created bookmark those properties which are needed for a bookmark/alias file
880 typedef CFOptionFlags CFURLBookmarkCreationOptions
;
883 kCFBookmarkResolutionWithoutUIMask
= ( 1UL << 8 ), // don't perform any UI during bookmark resolution
884 kCFBookmarkResolutionWithoutMountingMask
= ( 1UL << 9 ), // don't mount a volume during bookmark resolution
886 typedef CFOptionFlags CFURLBookmarkResolutionOptions
;
888 typedef CFOptionFlags CFURLBookmarkFileCreationOptions
;
890 /* @function CFURLCreateBookmarkData
891 @discussion Create a CFDataRef containing an externalizable representation from a CFURLRef, modified with the given options, including ( at the minimum ) any
892 properties in the propertiesToInclude array which are retrievable from the given url.
893 @param allocator the CFAllocator to use to create this object
894 @param url the CFURLRef to create a bookmark data from.
895 @param options a set of options which control creation of the bookmark data
896 @param resourcePropertiesToInclude If non-NULL, an CFArrayRef of additional properties copied from the url to include in the created bookmark data.
897 @param relativeToURL If non-NULL, the created bookmark will be relative to the given url
898 @param error If non-NULL, on exit will be filled in with a CFErrorRef representing any error which occured during creation of the bookmark data
899 @result A CFDataRef containing an data, which can be later be passed to CFURLCreateByResolvingBookmarkData() or to CFURLCopyPropertiesForKeysFromBookmarkData() / CFURLCopyPropertyForKeyFromBookmarkData() */
901 CFDataRef
CFURLCreateBookmarkData ( CFAllocatorRef allocator
, CFURLRef url
, CFURLBookmarkCreationOptions options
, CFArrayRef resourcePropertiesToInclude
, CFURLRef relativeToURL
, CFErrorRef
* error
) CF_AVAILABLE(10_6
, 4_0
);
903 /* @function CFURLCreateByResolvingBookmarkData
904 @discussion Given a CFDataRef created with CFURLCreateBookmarkRepresentation(), return a CFURLRef of the item it was a bookmark to, and
905 attempt to pre-cache those properties in propertiesToInclude in the resulting url. If in the process of resolving the bookmark into the CFURLRef
906 it points to this determines that some properties in the bookmark are out of date or not correct for the item it resolves to, set *isStale to YES,
907 which the client may want to use to decide to make a new bookmark from the returned item and replace the saved bookmark it has. If the bookmarked
908 item cannot be found, return NULL. If an error ( other than "original item can not be found" ) occurs during the process, return NULL and fill in error )
909 @param allocator the CFAllocator to use to create this object
910 @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData
911 @param options options which affect the resolution
912 @param relativeToURL If non-NULL, and if the bookmark was created relative to another url, then resolve it relative to this url
913 @param resourcePropertiesToInclude If non-NULL, a CFArray containing those properties which the caller would like to already be cached on the given url
914 @param isStale If non-NULL, on exit will be set to true if during resolution any of the properties in the bookmark no longer seemed to match the
915 corresponding properties on the returned file. Clients, upon seeing a stale representation, may want to replace whatever stored bookmark data they
916 have saved and create a new one.
917 @param error If non-NULL, on exit will be filled in with a CFErrorRef representing any error which occured during resolution of the bookmark data
918 @result A CFURLRef of a file which is the closest match to the file the bookmark data */
920 CFURLRef
CFURLCreateByResolvingBookmarkData ( CFAllocatorRef allocator
, CFDataRef bookmark
, CFURLBookmarkResolutionOptions options
, CFURLRef relativeToURL
, CFArrayRef resourcePropertiesToInclude
, Boolean
* isStale
, CFErrorRef
* error
) CF_AVAILABLE(10_6
, 4_0
);
922 /* @function CFURLCreatePropertiesForKeysFromBookmarkData
923 @discussion Given a bookmark, return a dictionary of properties ( all properties if propertiesToReturn == NULL ).
924 This returns only the properties stored within the bookmark and will not attempt to resolve the bookmark or do i/o.
925 @param allocator the CFAllocator to use to create this object
926 @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData
927 @param propertiesToReturn a CFArrayRef of the properties of the bookmark data which the client would like returned.
928 @result a CFDictionaryRef containing the values for the properties passed in obtained from the bookmark data ( not by attempting to resolve it or do i/o in any way ) */
930 CFDictionaryRef
CFURLCreateResourcePropertiesForKeysFromBookmarkData ( CFAllocatorRef allocator
, CFArrayRef resourcePropertiesToReturn
, CFDataRef bookmark
) CF_AVAILABLE(10_6
, 4_0
);
932 /* @function CFURLCreatePropertyForKeyFromBookmarkData
933 @discussion Given a bookmark, return the value for a given property from the bookmark data
934 This returns only the properties stored within the bookmark and will not attempt to resolve the bookmark or do i/o.
935 @param allocator the CFAllocator to use to create this object
936 @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData
937 @param propertyKey the property key to return.
938 @result a CFTypeRef value for the property passed in obtained from the bookmark data ( not by attempting to resolve it or do i/o in any way ) */
940 CFTypeRef
CFURLCreateResourcePropertyForKeyFromBookmarkData( CFAllocatorRef allocator
, CFStringRef resourcePropertyKey
, CFDataRef bookmark
) CF_AVAILABLE(10_6
, 4_0
);
942 /*! @function CFURLCreateBookmarkDataFromFile
943 @description Given a fileURL of a file which is a Finder "alias" file, return a CFDataRef with the bookmark data from the file. If urlRef points to an alias file
944 created before SnowLeopard which contains Alias Manager information and no bookmark data, then a CFDataRef will be synthesized which contains
945 a approximation of the alias information in a format which can be used to resolve the bookmark. If an error prevents reading the data or
946 if it is corrupt, NULL will be returned and error will be filled in if errorRef is non-NULL.
947 @param allocator the CFAllocator to use to create this object
948 @param fileURL a CFURLRef to to the alias file to create the bookmark data from
949 @param errorRef if non-NULL, on exit will be filled in with a CFErrorRef representing any error which occurred during the creation of the bookmark data from the file
950 @result A CFDataRef containing bookmark data, or NULL if there was an error creating bookmark data from the file, such as if the file is not an alias file.
953 CFDataRef
CFURLCreateBookmarkDataFromFile(CFAllocatorRef allocator
, CFURLRef fileURL
, CFErrorRef
*errorRef
) CF_AVAILABLE(10_6
, 5_0
);
955 /*! @function CFURLWriteBookmarkDataToFile
956 @description Given a created bookmarkData object, create a new Finder "alias" file at fileURL which contains the bookmark data. If fileURL is a url to a directory, an alias file
957 will be created with the same name as the bookmarked item and a ".alias" extension. If fileURL is a url for a file and it exists it will be overwritten. If a
958 .alias extension is not present it will be added. In addition to the bookmark data, sufficient pre-SnowLeopard alias data will added to the file to allow
959 systems running something before SnowLeopard to resolve this file using Alias Manager routines and get back the same file as the bookmark routines.
960 The bookmark data must have been created with the kCFURLBookmarkCreationSuitableForBookmarkFile option and an error will be returned if not.
961 @param allocator the CFAllocator to use to create this object
962 @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData
963 @param options options flags
964 @param errorRef if non-NULL, on exit will be filled in with a CFErrorRef representing any error which occurred during the creation of the alias file
967 Boolean
CFURLWriteBookmarkDataToFile( CFDataRef bookmarkRef
, CFURLRef fileURL
, CFURLBookmarkFileCreationOptions options
, CFErrorRef
*errorRef
) CF_AVAILABLE(10_6
, 5_0
);
969 /*! @function CFURLCreateBookmarkDataFromAliasRecord
970 @discussion Create a CFDataRef containing bookmarkdata by converting the alias data in aliasRecordDataRef, which should be the contents of an AliasRecord copied into a CFDataRef object.
971 The created bookmarkdata can be passed into CFURLCreateByResolvingBookmarkData() to resolve the item into a CFURLRef, or a small set of information can be returned from
972 CFURLCreateResourcePropertiesForKeysFromBookmarkData() / CFURLCreateResourcePropertyForKeyFromBookmarkData().
973 @param allocator the CFAllocator to use to create this object
974 @param aliasRecordDataRef the contents of an AliasRecord to create bookmark data for
975 @result A CFDataRef containing an data, which can be later be passed to CFURLCreateByResolvingBookmarkData() or to CFURLCopyPropertiesForKeysFromBookmarkData() / CFURLCopyPropertyForKeyFromBookmarkData()
978 CFDataRef
CFURLCreateBookmarkDataFromAliasRecord ( CFAllocatorRef allocatorRef
, CFDataRef aliasRecordDataRef
) CF_AVAILABLE_MAC(10_6
);
980 #endif /* TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE */
984 #endif /* ! __COREFOUNDATION_CFURL__ */