2 * Copyright (c) 2012 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-2012, 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>
36 CF_IMPLICIT_BRIDGING_ENABLED
39 typedef CF_ENUM(CFIndex
, CFURLPathStyle
) {
40 kCFURLPOSIXPathStyle
= 0,
41 kCFURLHFSPathStyle
, /* The use of kCFURLHFSPathStyle is deprecated. The Carbon File Manager, which uses HFS style paths, is deprecated. HFS style paths are unreliable because they can arbitrarily refer to multiple volumes if those volumes have identical volume names. You should instead use kCFURLPOSIXPathStyle wherever possible. */
42 kCFURLWindowsPathStyle
45 typedef const struct __CFURL
* CFURLRef
;
47 /* CFURLs are composed of two fundamental pieces - their string, and a */
48 /* (possibly NULL) base URL. A relative URL is one in which the string */
49 /* by itself does not fully specify the URL (for instance "myDir/image.tiff"); */
50 /* an absolute URL is one in which the string does fully specify the URL */
51 /* ("file://localhost/myDir/image.tiff"). Absolute URLs always have NULL */
52 /* base URLs; however, it is possible for a URL to have a NULL base, and still */
53 /* not be absolute. Such a URL has only a relative string, and cannot be */
54 /* resolved. Two CFURLs are considered equal if and only if their strings */
55 /* are equal and their bases are equal. In other words, */
56 /* "file://localhost/myDir/image.tiff" is NOT equal to the URL with relative */
57 /* string "myDir/image.tiff" and base URL "file://localhost/". Clients that */
58 /* need these less strict form of equality should convert all URLs to their */
59 /* absolute form via CFURLCopyAbsoluteURL(), then compare the absolute forms. */
62 CFTypeID
CFURLGetTypeID(void);
64 /* encoding will be used both to interpret the bytes of URLBytes, and to */
65 /* interpret any percent-escapes within the bytes. */
67 CFURLRef
CFURLCreateWithBytes(CFAllocatorRef allocator
, const UInt8
*URLBytes
, CFIndex length
, CFStringEncoding encoding
, CFURLRef baseURL
);
69 /* Escapes any character that is not 7-bit ASCII with the byte-code */
70 /* for the given encoding. If escapeWhitespace is true, whitespace */
71 /* characters (' ', '\t', '\r', '\n') will be escaped also (desirable */
72 /* if embedding the URL into a larger text stream like HTML) */
74 CFDataRef
CFURLCreateData(CFAllocatorRef allocator
, CFURLRef url
, CFStringEncoding encoding
, Boolean escapeWhitespace
);
76 /* Any escape sequences in URLString will be interpreted via UTF-8. */
78 CFURLRef
CFURLCreateWithString(CFAllocatorRef allocator
, CFStringRef URLString
, CFURLRef baseURL
);
80 /* Create an absolute URL directly, without requiring the extra step */
81 /* of calling CFURLCopyAbsoluteURL(). If useCompatibilityMode is */
82 /* true, the rules historically used on the web are used to resolve */
83 /* relativeString against baseURL - these rules are generally listed */
84 /* in the RFC as optional or alternate interpretations. Otherwise, */
85 /* the strict rules from the RFC are used. The major differences are */
86 /* that in compatibility mode, we are lenient of the scheme appearing */
87 /* in relative portion, leading "../" components are removed from the */
88 /* final URL's path, and if the relative portion contains only */
89 /* resource specifier pieces (query, parameters, and fragment), then */
90 /* the last path component of the base URL will not be deleted */
92 CFURLRef
CFURLCreateAbsoluteURLWithBytes(CFAllocatorRef alloc
, const UInt8
*relativeURLBytes
, CFIndex length
, CFStringEncoding encoding
, CFURLRef baseURL
, Boolean useCompatibilityMode
);
94 /* filePath should be the URL's path expressed as a path of the type */
95 /* fsType. If filePath is not absolute, the resulting URL will be */
96 /* considered relative to the current working directory (evaluated */
97 /* at creation time). isDirectory determines whether filePath is */
98 /* treated as a directory path when resolving against relative path */
101 CFURLRef
CFURLCreateWithFileSystemPath(CFAllocatorRef allocator
, CFStringRef filePath
, CFURLPathStyle pathStyle
, Boolean isDirectory
);
104 CFURLRef
CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator
, const UInt8
*buffer
, CFIndex bufLen
, Boolean isDirectory
);
106 /* The path style of the baseURL must match the path style of the relative */
107 /* url or the results are undefined. If the provided filePath looks like an */
108 /* absolute path ( starting with '/' if pathStyle is kCFURLPosixPathStyle, */
109 /* not starting with ':' for kCFURLHFSPathStyle, or starting with what looks */
110 /* like a drive letter and colon for kCFURLWindowsPathStyle ) then the baseURL */
113 CFURLRef
CFURLCreateWithFileSystemPathRelativeToBase(CFAllocatorRef allocator
, CFStringRef filePath
, CFURLPathStyle pathStyle
, Boolean isDirectory
, CFURLRef baseURL
);
116 CFURLRef
CFURLCreateFromFileSystemRepresentationRelativeToBase(CFAllocatorRef allocator
, const UInt8
*buffer
, CFIndex bufLen
, Boolean isDirectory
, CFURLRef baseURL
);
118 /* Fills buffer with the file system's native representation of */
119 /* url's path. No more than maxBufLen bytes are written to buffer. */
120 /* The buffer should be at least the maximum path length for */
121 /* the file system in question to avoid failures for insufficiently */
122 /* large buffers. If resolveAgainstBase is true, the url's relative */
123 /* portion is resolved against its base before the path is computed. */
124 /* Returns success or failure. */
126 Boolean
CFURLGetFileSystemRepresentation(CFURLRef url
, Boolean resolveAgainstBase
, UInt8
*buffer
, CFIndex maxBufLen
);
128 /* Creates a new URL by resolving the relative portion of relativeURL against its base. */
130 CFURLRef
CFURLCopyAbsoluteURL(CFURLRef relativeURL
);
132 /* Returns the URL's string. */
134 CFStringRef
CFURLGetString(CFURLRef anURL
);
136 /* Returns the base URL if it exists */
138 CFURLRef
CFURLGetBaseURL(CFURLRef anURL
);
141 All URLs can be broken into two pieces - the scheme (preceding the
142 first colon) and the resource specifier (following the first colon).
143 Most URLs are also "standard" URLs conforming to RFC 1808 (available
144 from www.w3c.org). This category includes URLs of the file, http,
145 https, and ftp schemes, to name a few. Standard URLs start the
146 resource specifier with two slashes ("//"), and can be broken into
147 four distinct pieces - the scheme, the net location, the path, and
148 further resource specifiers (typically an optional parameter, query,
149 and/or fragment). The net location appears immediately following
150 the two slashes and goes up to the next slash; it's format is
151 scheme-specific, but is usually composed of some or all of a username,
152 password, host name, and port. The path is a series of path components
153 separated by slashes; if the net location is present, the path always
154 begins with a slash. Standard URLs can be relative to another URL,
155 in which case at least the scheme and possibly other pieces as well
156 come from the base URL (see RFC 1808 for precise details when resolving
157 a relative URL against its base). The full URL is therefore
159 <scheme> "://" <net location> <path, always starting with slash> <add'l resource specifiers>
161 If a given CFURL can be decomposed (that is, conforms to RFC 1808), you
162 can ask for each of the four basic pieces (scheme, net location, path,
163 and resource specifer) separately, as well as for its base URL. The
164 basic pieces are returned with any percent escape sequences still in
165 place (although note that the scheme may not legally include any
166 percent escapes); this is to allow the caller to distinguish between
167 percent sequences that may have syntactic meaning if replaced by the
168 character being escaped (for instance, a '/' in a path component).
169 Since only the individual schemes know which characters are
170 syntactically significant, CFURL cannot safely replace any percent
171 escape sequences. However, you can use
172 CFURLCreateStringByReplacingPercentEscapes() to create a new string with
173 the percent escapes removed; see below.
175 If a given CFURL can not be decomposed, you can ask for its scheme and its
176 resource specifier; asking it for its net location or path will return NULL.
178 To get more refined information about the components of a decomposable
179 CFURL, you may ask for more specific pieces of the URL, expressed with
180 the percent escapes removed. The available functions are CFURLCopyHostName(),
181 CFURLGetPortNumber() (returns an Int32), CFURLCopyUserName(),
182 CFURLCopyPassword(), CFURLCopyQuery(), CFURLCopyParameters(), and
183 CFURLCopyFragment(). Because the parameters, query, and fragment of an
184 URL may contain scheme-specific syntaxes, these methods take a second
185 argument, giving a list of characters which should NOT be replaced if
186 percent escaped. For instance, the ftp parameter syntax gives simple
187 key-value pairs as "<key>=<value>;" Clearly if a key or value includes
188 either '=' or ';', it must be escaped to avoid corrupting the meaning of
189 the parameters, so the caller may request the parameter string as
191 CFStringRef myParams = CFURLCopyParameters(ftpURL, CFSTR("=;%"));
193 requesting that all percent escape sequences be replaced by the represented
194 characters, except for escaped '=', '%' or ';' characters. Pass the empty
195 string (CFSTR("")) to request that all percent escapes be replaced, or NULL
196 to request that none be.
199 /* Returns true if anURL conforms to RFC 1808 */
201 Boolean
CFURLCanBeDecomposed(CFURLRef anURL
);
203 /* The next several methods leave any percent escape sequences intact */
206 CFStringRef
CFURLCopyScheme(CFURLRef anURL
);
208 /* NULL if CFURLCanBeDecomposed(anURL) is false */
210 CFStringRef
CFURLCopyNetLocation(CFURLRef anURL
);
212 /* NULL if CFURLCanBeDecomposed(anURL) is false; also does not resolve the URL */
213 /* against its base. See also CFURLCopyAbsoluteURL(). Note that, strictly */
214 /* speaking, any leading '/' is not considered part of the URL's path, although */
215 /* its presence or absence determines whether the path is absolute. */
216 /* CFURLCopyPath()'s return value includes any leading slash (giving the path */
217 /* the normal POSIX appearance); CFURLCopyStrictPath()'s return value omits any */
218 /* leading slash, and uses isAbsolute to report whether the URL's path is absolute. */
220 /* CFURLCopyFileSystemPath() returns the URL's path as a file system path for the */
221 /* given path style. All percent escape sequences are replaced. The URL is not */
222 /* resolved against its base before computing the path. */
224 CFStringRef
CFURLCopyPath(CFURLRef anURL
);
227 CFStringRef
CFURLCopyStrictPath(CFURLRef anURL
, Boolean
*isAbsolute
);
230 CFStringRef
CFURLCopyFileSystemPath(CFURLRef anURL
, CFURLPathStyle pathStyle
);
232 /* Returns whether anURL's path represents a directory */
233 /* (true returned) or a simple file (false returned) */
235 Boolean
CFURLHasDirectoryPath(CFURLRef anURL
);
237 /* Any additional resource specifiers after the path. For URLs */
238 /* that cannot be decomposed, this is everything except the scheme itself. */
240 CFStringRef
CFURLCopyResourceSpecifier(CFURLRef anURL
);
243 CFStringRef
CFURLCopyHostName(CFURLRef anURL
);
246 SInt32
CFURLGetPortNumber(CFURLRef anURL
); /* Returns -1 if no port number is specified */
249 CFStringRef
CFURLCopyUserName(CFURLRef anURL
);
252 CFStringRef
CFURLCopyPassword(CFURLRef anURL
);
254 /* These remove all percent escape sequences except those for */
255 /* characters in charactersToLeaveEscaped. If charactersToLeaveEscaped */
256 /* is empty (""), all percent escape sequences are replaced by their */
257 /* corresponding characters. If charactersToLeaveEscaped is NULL, */
258 /* then no escape sequences are removed at all */
260 CFStringRef
CFURLCopyParameterString(CFURLRef anURL
, CFStringRef charactersToLeaveEscaped
);
263 CFStringRef
CFURLCopyQueryString(CFURLRef anURL
, CFStringRef charactersToLeaveEscaped
);
266 CFStringRef
CFURLCopyFragment(CFURLRef anURL
, CFStringRef charactersToLeaveEscaped
);
269 CFStringRef
CFURLCopyLastPathComponent(CFURLRef url
);
272 CFStringRef
CFURLCopyPathExtension(CFURLRef url
);
274 /* These functions all treat the base URL of the supplied url as */
275 /* invariant. In other words, the URL returned will always have */
276 /* the same base as the URL supplied as an argument. */
279 CFURLRef
CFURLCreateCopyAppendingPathComponent(CFAllocatorRef allocator
, CFURLRef url
, CFStringRef pathComponent
, Boolean isDirectory
);
282 CFURLRef
CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator
, CFURLRef url
);
285 CFURLRef
CFURLCreateCopyAppendingPathExtension(CFAllocatorRef allocator
, CFURLRef url
, CFStringRef extension
);
288 CFURLRef
CFURLCreateCopyDeletingPathExtension(CFAllocatorRef allocator
, CFURLRef url
);
290 /* Fills buffer with the bytes for url, returning the number of bytes */
291 /* filled. If buffer is of insufficient size, returns -1 and no bytes */
292 /* are placed in buffer. If buffer is NULL, the needed length is */
293 /* computed and returned. The returned bytes are the original bytes */
294 /* from which the URL was created; if the URL was created from a */
295 /* string, the bytes will be the bytes of the string encoded via UTF-8 */
297 CFIndex
CFURLGetBytes(CFURLRef url
, UInt8
*buffer
, CFIndex bufferLength
);
299 typedef CF_ENUM(CFIndex
, CFURLComponentType
) {
300 kCFURLComponentScheme
= 1,
301 kCFURLComponentNetLocation
= 2,
302 kCFURLComponentPath
= 3,
303 kCFURLComponentResourceSpecifier
= 4,
305 kCFURLComponentUser
= 5,
306 kCFURLComponentPassword
= 6,
307 kCFURLComponentUserInfo
= 7,
308 kCFURLComponentHost
= 8,
309 kCFURLComponentPort
= 9,
310 kCFURLComponentParameterString
= 10,
311 kCFURLComponentQuery
= 11,
312 kCFURLComponentFragment
= 12
316 Gets the range of the requested component in the bytes of url, as
317 returned by CFURLGetBytes(). This range is only good for use in the
318 bytes returned by CFURLGetBytes!
320 If non-NULL, rangeIncludingSeparators gives the range of component
321 including the sequences that separate component from the previous and
322 next components. If there is no previous or next component, that end of
323 rangeIncludingSeparators will match the range of the component itself.
324 If url does not contain the given component type, (kCFNotFound, 0) is
325 returned, and rangeIncludingSeparators is set to the location where the
326 component would be inserted. Some examples -
328 For the URL http://www.apple.com/hotnews/
330 Component returned range rangeIncludingSeparators
332 net location (7, 13) (4, 16)
334 resource specifier (kCFNotFound, 0) (29, 0)
335 user (kCFNotFound, 0) (7, 0)
336 password (kCFNotFound, 0) (7, 0)
337 user info (kCFNotFound, 0) (7, 0)
339 port (kCFNotFound, 0) (20, 0)
340 parameter (kCFNotFound, 0) (29, 0)
341 query (kCFNotFound, 0) (29, 0)
342 fragment (kCFNotFound, 0) (29, 0)
345 For the URL ./relPath/file.html#fragment
347 Component returned range rangeIncludingSeparators
348 scheme (kCFNotFound, 0) (0, 0)
349 net location (kCFNotFound, 0) (0, 0)
351 resource specifier (20, 8) (19, 9)
352 user (kCFNotFound, 0) (0, 0)
353 password (kCFNotFound, 0) (0, 0)
354 user info (kCFNotFound, 0) (0, 0)
355 host (kCFNotFound, 0) (0, 0)
356 port (kCFNotFound, 0) (0, 0)
357 parameter (kCFNotFound, 0) (19, 0)
358 query (kCFNotFound, 0) (19, 0)
359 fragment (20, 8) (19, 9)
362 For the URL scheme://user:pass@host:1/path/path2/file.html;params?query#fragment
364 Component returned range rangeIncludingSeparators
366 net location (9, 16) (6, 19)
367 path (25, 21) (25, 22)
368 resource specifier (47, 21) (46, 22)
370 password (14, 4) (13, 6)
371 user info (9, 9) (6, 13)
374 parameter (47, 6) (46, 8)
375 query (54, 5) (53, 7)
376 fragment (60, 8) (59, 9)
379 CFRange
CFURLGetByteRangeForComponent(CFURLRef url
, CFURLComponentType component
, CFRange
*rangeIncludingSeparators
);
381 /* Returns a string with any percent escape sequences that do NOT */
382 /* correspond to characters in charactersToLeaveEscaped with their */
383 /* equivalent. Returns NULL on failure (if an invalid percent sequence */
384 /* is encountered), or the original string (retained) if no characters */
385 /* need to be replaced. Pass NULL to request that no percent escapes be */
386 /* replaced, or the empty string (CFSTR("")) to request that all percent */
387 /* escapes be replaced. Uses UTF8 to interpret percent escapes. */
389 CFStringRef
CFURLCreateStringByReplacingPercentEscapes(CFAllocatorRef allocator
, CFStringRef originalString
, CFStringRef charactersToLeaveEscaped
);
391 /* As above, but allows you to specify the encoding to use when interpreting percent escapes */
393 CFStringRef
CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFAllocatorRef allocator
, CFStringRef origString
, CFStringRef charsToLeaveEscaped
, CFStringEncoding encoding
);
395 /* Creates a copy or originalString, replacing certain characters with */
396 /* the equivalent percent escape sequence based on the encoding specified. */
397 /* If the originalString does not need to be modified (no percent escape */
398 /* sequences are missing), may retain and return originalString. */
399 /* If you are uncertain of the correct encoding, you should use UTF-8, */
400 /* which is the encoding designated by RFC 2396 as the correct encoding */
401 /* for use in URLs. The characters so escaped are all characters that */
402 /* are not legal URL characters (based on RFC 2396), plus any characters */
403 /* in legalURLCharactersToBeEscaped, less any characters in */
404 /* charactersToLeaveUnescaped. To simply correct any non-URL characters */
405 /* in an otherwise correct URL string, do: */
407 /* newString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, origString, NULL, NULL, kCFStringEncodingUTF8); */
409 CFStringRef
CFURLCreateStringByAddingPercentEscapes(CFAllocatorRef allocator
, CFStringRef originalString
, CFStringRef charactersToLeaveUnescaped
, CFStringRef legalURLCharactersToBeEscaped
, CFStringEncoding encoding
);
412 #if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION
413 CF_IMPLICIT_BRIDGING_DISABLED
416 CFURLCreateFileReferenceURL
418 Returns a new file reference URL that refers to the same resource as a specified URL.
422 The memory allocator for creating the new URL.
424 The file URL specifying the resource.
426 On output when the result is NULL, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error.
429 The new file reference URL, or NULL if an error occurs.
432 File reference URLs use a URL path syntax that identifies a file system object by reference, not by path. This form of file URL remains valid when the file system path of the URL’s underlying resource changes. An error will occur if the url parameter is not a file URL. File reference URLs cannot be created to file system objects which do not exist or are not reachable. In some areas of the file system hierarchy, file reference URLs cannot be generated to the leaf node of the URL path. A file reference URL's path should never be persistently stored because is not valid across system restarts, and across remounts of volumes -- if you want to create a persistent reference to a file system object, use a bookmark (see CFURLCreateBookmarkData). If this function returns NULL, the optional error is populated. This function is currently applicable only to URLs for file system resources.
433 Symbol is present in iOS 4, but performs no operation.
436 CFURLRef
CFURLCreateFileReferenceURL(CFAllocatorRef allocator
, CFURLRef url
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
440 CFURLCreateFilePathURL
442 Returns a new file path URL that refers to the same resource as a specified URL.
446 The memory allocator for creating the new URL.
448 The file URL specifying the resource.
450 On output when the result is NULL, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error.
453 The new file path URL, or NULL if an error occurs.
456 File path URLs use a file system style path. An error will occur if the url parameter is not a file URL. A file reference URL's resource must exist and be reachable to be converted to a file path URL. If this function returns NULL, the optional error is populated. This function is currently applicable only to URLs for file system resources.
457 Symbol is present in iOS 4, but performs no operation.
460 CFURLRef
CFURLCreateFilePathURL(CFAllocatorRef allocator
, CFURLRef url
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
462 CF_IMPLICIT_BRIDGING_ENABLED
467 #if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION
468 CF_IMPLICIT_BRIDGING_DISABLED
472 The behavior of resource value caching is slightly different between the NSURL and CFURL API.
474 When the NSURL methods which get, set, or use cached resource values are used from the main thread, resource values cached by the URL (except those added as temporary properties) are invalidated the next time the main thread's run loop runs.
476 The CFURL functions do not automatically clear any resource values cached by the URL. The client has complete control over the cache lifetime. If you are using CFURL API, you must use CFURLClearResourcePropertyCacheForKey or CFURLClearResourcePropertyCache to clear cached resource values.
481 CFURLCopyResourcePropertyForKey
483 Returns the resource value identified by a given resource key.
487 The URL specifying the resource.
489 The resource key that identifies the resource property.
490 propertyValueTypeRefPtr
491 On output when the result is true, the resource value or NULL.
493 On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error.
496 true if propertyValueTypeRefPtr is successfully populated; false if an error occurs.
499 CFURLCopyResourcePropertyForKey first checks if the URL object already caches the resource value. If so, it returns the cached resource value to the caller. If not, then CFURLCopyResourcePropertyForKey synchronously obtains the resource value from the backing store, adds the resource value to the URL object's cache, and returns the resource value to the caller. The type of the resource value varies by resource property (see resource key definitions). If this function returns true and propertyValueTypeRefPtr is populated with NULL, it means the resource property is not available for the specified resource and no errors occurred when determining the resource property was not available. If this function returns false, the optional error is populated. This function is currently applicable only to URLs for file system resources.
500 Symbol is present in iOS 4, but performs no operation.
503 Boolean
CFURLCopyResourcePropertyForKey(CFURLRef url
, CFStringRef key
, void *propertyValueTypeRefPtr
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
507 CFURLCopyResourcePropertiesForKeys
509 Returns the resource values identified by specified array of resource keys.
513 The URL specifying the resource.
515 An array of resource keys that identify the resource properties.
517 On output when the result is NULL, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error.
520 A dictionary of resource values indexed by resource key; NULL if an error occurs.
523 CFURLCopyResourcePropertiesForKeys first checks if the URL object already caches the resource values. If so, it returns the cached resource values to the caller. If not, then CFURLCopyResourcePropertyForKey synchronously obtains the resource values from the backing store, adds the resource values to the URL object's cache, and returns the resource values to the caller. The type of the resource values vary by property (see resource key definitions). If the result dictionary does not contain a resource value for one or more of the requested resource keys, it means those resource properties are not available for the specified resource and no errors occurred when determining those resource properties were not available. If this function returns NULL, the optional error is populated. This function is currently applicable only to URLs for file system resources.
524 Symbol is present in iOS 4, but performs no operation.
527 CFDictionaryRef
CFURLCopyResourcePropertiesForKeys(CFURLRef url
, CFArrayRef keys
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
531 CFURLSetResourcePropertyForKey
533 Sets the resource value identified by a given resource key.
537 The URL specifying the resource.
539 The resource key that identifies the resource property.
543 On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error.
546 true if the attempt to set the resource value completed with no errors; otherwise, false.
549 CFURLSetResourcePropertyForKey writes the new resource value out to the backing store. Attempts to set a read-only resource property or to set a resource property not supported by the resource are ignored and are not considered errors. If this function returns false, the optional error is populated. This function is currently applicable only to URLs for file system resources.
550 Symbol is present in iOS 4, but performs no operation.
553 Boolean
CFURLSetResourcePropertyForKey(CFURLRef url
, CFStringRef key
, CFTypeRef propertyValue
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
557 CFURLSetResourcePropertiesForKeys
559 Sets any number of resource values of a URL's resource.
563 The URL specifying the resource.
565 A dictionary of resource values indexed by resource keys.
567 On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error.
570 true if the attempt to set the resource values completed with no errors; otherwise, false.
573 CFURLSetResourcePropertiesForKeys writes the new resource values out to the backing store. Attempts to set read-only resource properties or to set resource properties not supported by the resource are ignored and are not considered errors. If an error occurs after some resource properties have been successfully changed, the userInfo dictionary in the returned error contains an array of resource keys that were not set with the key kCFURLKeysOfUnsetValuesKey. The order in which the resource values are set is not defined. If you need to guarantee the order resource values are set, you should make multiple requests to CFURLSetResourcePropertiesForKeys or CFURLSetResourcePropertyForKey to guarantee the order. If this function returns false, the optional error is populated. This function is currently applicable only to URLs for file system resources.
574 Symbol is present in iOS 4, but performs no operation.
577 Boolean
CFURLSetResourcePropertiesForKeys(CFURLRef url
, CFDictionaryRef keyedPropertyValues
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
581 const CFStringRef kCFURLKeysOfUnsetValuesKey
CF_AVAILABLE(10_7
, 5_0
);
582 /* Key for the resource properties that have not been set after the CFURLSetResourcePropertiesForKeys function returns an error, returned as an array of of CFString objects. */
586 CFURLClearResourcePropertyCacheForKey
588 Discards a cached resource value of a URL.
592 The URL specifying the resource.
594 The resource key that identifies the resource property.
597 Discarding a cached resource value may discard other cached resource values, because some resource values are cached as a set of values and because some resource values depend on other resource values (temporary properties have no dependencies). This function is currently applicable only to URLs for file system resources.
598 Symbol is present in iOS 4, but performs no operation.
601 void CFURLClearResourcePropertyCacheForKey(CFURLRef url
, CFStringRef key
) CF_AVAILABLE(10_6
, 4_0
);
605 CFURLClearResourcePropertyCache
607 Discards all cached resource values of a URL.
611 The URL specifying the resource.
614 All temporary properties are also cleared from the URL object's cache. This function is currently applicable only to URLs for file system resources.
615 Symbol is present in iOS 4, but performs no operation.
618 void CFURLClearResourcePropertyCache(CFURLRef url
) CF_AVAILABLE(10_6
, 4_0
);
622 CFURLSetTemporaryResourcePropertyForKey
624 Sets a temporary resource value on the URL object.
630 The resource key that identifies the temporary resource property.
635 Temporary properties are for client use. Temporary properties exist only in memory and are never written to the resource's backing store. Once set, a temporary value can be copied from the URL object with CFURLCopyResourcePropertyForKey and CFURLCopyResourcePropertiesForKeys. To remove a temporary value from the URL object, use CFURLClearResourcePropertyCacheForKey. Temporary values must be valid Core Foundation types, and will be retained by CFURLSetTemporaryResourcePropertyForKey. Care should be taken to ensure the key that identifies a temporary resource property is unique and does not conflict with system defined keys (using reverse domain name notation in your temporary resource property keys is recommended). This function is currently applicable only to URLs for file system resources.
636 Symbol is present in iOS 4, but performs no operation.
639 void CFURLSetTemporaryResourcePropertyForKey(CFURLRef url
, CFStringRef key
, CFTypeRef propertyValue
) CF_AVAILABLE(10_6
, 4_0
);
643 CFURLResourceIsReachable
645 Returns whether the URL's resource exists and is reachable.
651 On output when the result is false, the error that occurred. This parameter is optional; if you do not wish the error returned, pass NULL here. The caller is responsible for releasing a valid output error.
654 true if the resource is reachable; otherwise, false.
657 CFURLResourceIsReachable synchronously checks if the resource's backing store is reachable. Checking reachability is appropriate when making decisions that do not require other immediate operations on the resource, e.g. periodic maintenance of UI state that depends on the existence of a specific document. When performing operations such as opening a file or copying resource properties, it is more efficient to simply try the operation and handle failures. This function is currently applicable only to URLs for file system resources. If this function returns false, the optional error is populated. For other URL types, false is returned.
658 Symbol is present in iOS 4, but performs no operation.
661 Boolean
CFURLResourceIsReachable(CFURLRef url
, CFErrorRef
*error
) CF_AVAILABLE(10_6
, 4_0
);
663 CF_IMPLICIT_BRIDGING_ENABLED
666 /* Properties of File System Resources */
669 const CFStringRef kCFURLNameKey
CF_AVAILABLE(10_6
, 4_0
);
670 /* The resource name provided by the file system (Read-write, value type CFString) */
673 const CFStringRef kCFURLLocalizedNameKey
CF_AVAILABLE(10_6
, 4_0
);
674 /* Localized or extension-hidden name as displayed to users (Read-only, value type CFString) */
677 const CFStringRef kCFURLIsRegularFileKey
CF_AVAILABLE(10_6
, 4_0
);
678 /* True for regular files (Read-only, value type CFBoolean) */
681 const CFStringRef kCFURLIsDirectoryKey
CF_AVAILABLE(10_6
, 4_0
);
682 /* True for directories (Read-only, CFBoolean) */
685 const CFStringRef kCFURLIsSymbolicLinkKey
CF_AVAILABLE(10_6
, 4_0
);
686 /* True for symlinks (Read-only, value type CFBoolean) */
689 const CFStringRef kCFURLIsVolumeKey
CF_AVAILABLE(10_6
, 4_0
);
690 /* True for the root directory of a volume (Read-only, value type CFBoolean) */
693 const CFStringRef kCFURLIsPackageKey
CF_AVAILABLE(10_6
, 4_0
);
694 /* True for packaged directories (Read-only 10_6 and 10_7, read-write 10_8, value type CFBoolean). Note: You can only set or clear this property on directories; if you try to set this property on non-directory objects, the property is ignored. If the directory is a package for some other reason (extension type, etc), setting this property to false will have no effect. */
697 const CFStringRef kCFURLIsSystemImmutableKey
CF_AVAILABLE(10_6
, 4_0
);
698 /* True for system-immutable resources (Read-write, value type CFBoolean) */
701 const CFStringRef kCFURLIsUserImmutableKey
CF_AVAILABLE(10_6
, 4_0
);
702 /* True for user-immutable resources (Read-write, value type CFBoolean) */
705 const CFStringRef kCFURLIsHiddenKey
CF_AVAILABLE(10_6
, 4_0
);
706 /* True for resources normally not displayed to users (Read-write, value type CFBoolean). Note: If the resource is a hidden because its name starts with a period, setting this property to false will not change the property. */
709 const CFStringRef kCFURLHasHiddenExtensionKey
CF_AVAILABLE(10_6
, 4_0
);
710 /* True for resources whose filename extension is removed from the localized name property (Read-write, value type CFBoolean) */
713 const CFStringRef kCFURLCreationDateKey
CF_AVAILABLE(10_6
, 4_0
);
714 /* The date the resource was created (Read-write, value type CFDate) */
717 const CFStringRef kCFURLContentAccessDateKey
CF_AVAILABLE(10_6
, 4_0
);
718 /* The date the resource was last accessed (Read-only, value type CFDate) */
721 const CFStringRef kCFURLContentModificationDateKey
CF_AVAILABLE(10_6
, 4_0
);
722 /* The time the resource content was last modified (Read-write, value type CFDate) */
725 const CFStringRef kCFURLAttributeModificationDateKey
CF_AVAILABLE(10_6
, 4_0
);
726 /* The time the resource's attributes were last modified (Read-write, value type CFDate) */
729 const CFStringRef kCFURLLinkCountKey
CF_AVAILABLE(10_6
, 4_0
);
730 /* Number of hard links to the resource (Read-only, value type CFNumber) */
733 const CFStringRef kCFURLParentDirectoryURLKey
CF_AVAILABLE(10_6
, 4_0
);
734 /* The resource's parent directory, if any (Read-only, value type CFURL) */
737 const CFStringRef kCFURLVolumeURLKey
CF_AVAILABLE(10_6
, 4_0
);
738 /* URL of the volume on which the resource is stored (Read-only, value type CFURL) */
741 const CFStringRef kCFURLTypeIdentifierKey
CF_AVAILABLE(10_6
, 4_0
);
742 /* Uniform type identifier (UTI) for the resource (Read-only, value type CFString) */
745 const CFStringRef kCFURLLocalizedTypeDescriptionKey
CF_AVAILABLE(10_6
, 4_0
);
746 /* User-visible type or "kind" description (Read-only, value type CFString) */
749 const CFStringRef kCFURLLabelNumberKey
CF_AVAILABLE(10_6
, 4_0
);
750 /* The label number assigned to the resource (Read-write, value type CFNumber) */
753 const CFStringRef kCFURLLabelColorKey
CF_AVAILABLE(10_6
, 4_0
);
754 /* The color of the assigned label (Currently not implemented, value type CGColorRef, must link with Application Services) */
757 const CFStringRef kCFURLLocalizedLabelKey
CF_AVAILABLE(10_6
, 4_0
);
758 /* The user-visible label text (Read-only, value type CFString) */
761 const CFStringRef kCFURLEffectiveIconKey
CF_AVAILABLE(10_6
, 4_0
);
762 /* The icon normally displayed for the resource (Read-only, value type CGImageRef, must link with Application Services) */
765 const CFStringRef kCFURLCustomIconKey
CF_AVAILABLE(10_6
, 4_0
);
766 /* The custom icon assigned to the resource, if any (Currently not implemented, value type CGImageRef, must link with Application Services) */
769 const CFStringRef kCFURLFileResourceIdentifierKey
CF_AVAILABLE(10_7
, 5_0
);
770 /* 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) */
773 const CFStringRef kCFURLVolumeIdentifierKey
CF_AVAILABLE(10_7
, 5_0
);
774 /* 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) */
777 const CFStringRef kCFURLPreferredIOBlockSizeKey
CF_AVAILABLE(10_7
, 5_0
);
778 /* The optimal block size when reading or writing this file's data, or NULL if not available. (Read-only, value type CFNumber) */
781 const CFStringRef kCFURLIsReadableKey
CF_AVAILABLE(10_7
, 5_0
);
782 /* true if this process (as determined by EUID) can read the resource. (Read-only, value type CFBoolean) */
785 const CFStringRef kCFURLIsWritableKey
CF_AVAILABLE(10_7
, 5_0
);
786 /* true if this process (as determined by EUID) can write to the resource. (Read-only, value type CFBoolean) */
789 const CFStringRef kCFURLIsExecutableKey
CF_AVAILABLE(10_7
, 5_0
);
790 /* true if this process (as determined by EUID) can execute a file resource or search a directory resource. (Read-only, value type CFBoolean) */
793 const CFStringRef kCFURLFileSecurityKey
CF_AVAILABLE(10_7
, 5_0
);
794 /* The file system object's security information encapsulated in a CFFileSecurity object. (Read-write, value type CFFileSecurity) */
797 const CFStringRef kCFURLIsExcludedFromBackupKey
CF_AVAILABLE(10_8
, 5_1
);
798 /* true if resource should be excluded from backups, false otherwise (Read-write, value type CFBoolean). This property is only useful for excluding cache and other application support files which are not needed in a backup. Some operations commonly made to user documents will cause this property to be reset to false and so this property should not be used on user documents. */
801 const CFStringRef kCFURLPathKey
CF_AVAILABLE(10_8
, 6_0
);
802 /* the URL's path as a file system path (Read-only, value type CFString) */
805 const CFStringRef kCFURLIsMountTriggerKey
CF_AVAILABLE(10_7
, 4_0
);
806 /* 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) */
809 const CFStringRef kCFURLFileResourceTypeKey
CF_AVAILABLE(10_7
, 5_0
);
810 /* Returns the file system object type. (Read-only, value type CFString) */
812 /* The file system object type values returned for the kCFURLFileResourceTypeKey */
814 const CFStringRef kCFURLFileResourceTypeNamedPipe
CF_AVAILABLE(10_7
, 5_0
);
816 const CFStringRef kCFURLFileResourceTypeCharacterSpecial
CF_AVAILABLE(10_7
, 5_0
);
818 const CFStringRef kCFURLFileResourceTypeDirectory
CF_AVAILABLE(10_7
, 5_0
);
820 const CFStringRef kCFURLFileResourceTypeBlockSpecial
CF_AVAILABLE(10_7
, 5_0
);
822 const CFStringRef kCFURLFileResourceTypeRegular
CF_AVAILABLE(10_7
, 5_0
);
824 const CFStringRef kCFURLFileResourceTypeSymbolicLink
CF_AVAILABLE(10_7
, 5_0
);
826 const CFStringRef kCFURLFileResourceTypeSocket
CF_AVAILABLE(10_7
, 5_0
);
828 const CFStringRef kCFURLFileResourceTypeUnknown
CF_AVAILABLE(10_7
, 5_0
);
830 /* File Properties */
833 const CFStringRef kCFURLFileSizeKey
CF_AVAILABLE(10_6
, 4_0
);
834 /* Total file size in bytes (Read-only, value type CFNumber) */
837 const CFStringRef kCFURLFileAllocatedSizeKey
CF_AVAILABLE(10_6
, 4_0
);
838 /* Total size allocated on disk for the file in bytes (number of blocks times block size) (Read-only, value type CFNumber) */
841 const CFStringRef kCFURLTotalFileSizeKey
CF_AVAILABLE(10_7
, 5_0
);
842 /* 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) */
845 const CFStringRef kCFURLTotalFileAllocatedSizeKey
CF_AVAILABLE(10_7
, 5_0
);
846 /* 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) */
849 const CFStringRef kCFURLIsAliasFileKey
CF_AVAILABLE(10_6
, 4_0
);
850 /* true if the resource is a Finder alias file or a symlink, false otherwise ( Read-only, value type CFBooleanRef) */
853 /* Volume Properties */
855 /* As a convenience, volume properties can be requested from any file system URL. The value returned will reflect the property value for the volume on which the resource is located. */
858 const CFStringRef kCFURLVolumeLocalizedFormatDescriptionKey
CF_AVAILABLE(10_6
, 4_0
);
859 /* The user-visible volume format (Read-only, value type CFString) */
862 const CFStringRef kCFURLVolumeTotalCapacityKey
CF_AVAILABLE(10_6
, 4_0
);
863 /* Total volume capacity in bytes (Read-only, value type CFNumber) */
866 const CFStringRef kCFURLVolumeAvailableCapacityKey
CF_AVAILABLE(10_6
, 4_0
);
867 /* Total free space in bytes (Read-only, value type CFNumber) */
870 const CFStringRef kCFURLVolumeResourceCountKey
CF_AVAILABLE(10_6
, 4_0
);
871 /* Total number of resources on the volume (Read-only, value type CFNumber) */
874 const CFStringRef kCFURLVolumeSupportsPersistentIDsKey
CF_AVAILABLE(10_6
, 4_0
);
875 /* true if the volume format supports persistent object identifiers and can look up file system objects by their IDs (Read-only, value type CFBoolean) */
878 const CFStringRef kCFURLVolumeSupportsSymbolicLinksKey
CF_AVAILABLE(10_6
, 4_0
);
879 /* true if the volume format supports symbolic links (Read-only, value type CFBoolean) */
882 const CFStringRef kCFURLVolumeSupportsHardLinksKey
CF_AVAILABLE(10_6
, 4_0
);
883 /* true if the volume format supports hard links (Read-only, value type CFBoolean) */
886 const CFStringRef kCFURLVolumeSupportsJournalingKey
CF_AVAILABLE(10_6
, 4_0
);
887 /* true if the volume format supports a journal used to speed recovery in case of unplanned restart (such as a power outage or crash). This does not necessarily mean the volume is actively using a journal. (Read-only, value type CFBoolean) */
890 const CFStringRef kCFURLVolumeIsJournalingKey
CF_AVAILABLE(10_6
, 4_0
);
891 /* true if the volume is currently using a journal for speedy recovery after an unplanned restart. (Read-only, value type CFBoolean) */
894 const CFStringRef kCFURLVolumeSupportsSparseFilesKey
CF_AVAILABLE(10_6
, 4_0
);
895 /* true if the volume format supports sparse files, that is, files which can have 'holes' that have never been written to, and thus do not consume space on disk. A sparse file may have an allocated size on disk that is less than its logical length. (Read-only, value type CFBoolean) */
898 const CFStringRef kCFURLVolumeSupportsZeroRunsKey
CF_AVAILABLE(10_6
, 4_0
);
899 /* For security reasons, parts of a file (runs) that have never been written to must appear to contain zeroes. true if the volume keeps track of allocated but unwritten runs of a file so that it can substitute zeroes without actually writing zeroes to the media. (Read-only, value type CFBoolean) */
902 const CFStringRef kCFURLVolumeSupportsCaseSensitiveNamesKey
CF_AVAILABLE(10_6
, 4_0
);
903 /* true if the volume format treats upper and lower case characters in file and directory names as different. Otherwise an upper case character is equivalent to a lower case character, and you can't have two names that differ solely in the case of the characters. (Read-only, value type CFBoolean) */
906 const CFStringRef kCFURLVolumeSupportsCasePreservedNamesKey
CF_AVAILABLE(10_6
, 4_0
);
907 /* true if the volume format preserves the case of file and directory names. Otherwise the volume may change the case of some characters (typically making them all upper or all lower case). (Read-only, value type CFBoolean) */
910 const CFStringRef kCFURLVolumeSupportsRootDirectoryDatesKey
CF_AVAILABLE(10_7
, 5_0
);
911 /* true if the volume supports reliable storage of times for the root directory. (Read-only, value type CFBoolean) */
914 const CFStringRef kCFURLVolumeSupportsVolumeSizesKey
CF_AVAILABLE(10_7
, 5_0
);
915 /* true if the volume supports returning volume size values (kCFURLVolumeTotalCapacityKey and kCFURLVolumeAvailableCapacityKey). (Read-only, value type CFBoolean) */
918 const CFStringRef kCFURLVolumeSupportsRenamingKey
CF_AVAILABLE(10_7
, 5_0
);
919 /* true if the volume can be renamed. (Read-only, value type CFBoolean) */
922 const CFStringRef kCFURLVolumeSupportsAdvisoryFileLockingKey
CF_AVAILABLE(10_7
, 5_0
);
923 /* 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) */
926 const CFStringRef kCFURLVolumeSupportsExtendedSecurityKey
CF_AVAILABLE(10_7
, 5_0
);
927 /* true if the volume implements extended security (ACLs). (Read-only, value type CFBoolean) */
930 const CFStringRef kCFURLVolumeIsBrowsableKey
CF_AVAILABLE(10_7
, 5_0
);
931 /* 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) */
934 const CFStringRef kCFURLVolumeMaximumFileSizeKey
CF_AVAILABLE(10_7
, 5_0
);
935 /* The largest file size (in bytes) supported by this file system, or NULL if this cannot be determined. (Read-only, value type CFNumber) */
938 const CFStringRef kCFURLVolumeIsEjectableKey
CF_AVAILABLE(10_7
, 5_0
);
939 /* true if the volume's media is ejectable from the drive mechanism under software control. (Read-only, value type CFBoolean) */
942 const CFStringRef kCFURLVolumeIsRemovableKey
CF_AVAILABLE(10_7
, 5_0
);
943 /* true if the volume's media is removable from the drive mechanism. (Read-only, value type CFBoolean) */
946 const CFStringRef kCFURLVolumeIsInternalKey
CF_AVAILABLE(10_7
, 5_0
);
947 /* 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) */
950 const CFStringRef kCFURLVolumeIsAutomountedKey
CF_AVAILABLE(10_7
, 5_0
);
951 /* true if the volume is automounted. Note: do not mistake this with the functionality provided by kCFURLVolumeSupportsBrowsingKey. (Read-only, value type CFBoolean) */
954 const CFStringRef kCFURLVolumeIsLocalKey
CF_AVAILABLE(10_7
, 5_0
);
955 /* true if the volume is stored on a local device. (Read-only, value type CFBoolean) */
958 const CFStringRef kCFURLVolumeIsReadOnlyKey
CF_AVAILABLE(10_7
, 5_0
);
959 /* true if the volume is read-only. (Read-only, value type CFBoolean) */
962 const CFStringRef kCFURLVolumeCreationDateKey
CF_AVAILABLE(10_7
, 5_0
);
963 /* The volume's creation date, or NULL if this cannot be determined. (Read-only, value type CFDate) */
966 const CFStringRef kCFURLVolumeURLForRemountingKey
CF_AVAILABLE(10_7
, 5_0
);
967 /* The CFURL needed to remount a network volume, or NULL if not available. (Read-only, value type CFURL) */
970 const CFStringRef kCFURLVolumeUUIDStringKey
CF_AVAILABLE(10_7
, 5_0
);
971 /* 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) */
974 const CFStringRef kCFURLVolumeNameKey
CF_AVAILABLE(10_7
, 5_0
);
975 /* The name of the volume (Read-write, settable if kCFURLVolumeSupportsRenamingKey is true and permissions allow, value type CFString) */
978 const CFStringRef kCFURLVolumeLocalizedNameKey
CF_AVAILABLE(10_7
, 5_0
);
979 /* The user-presentable name of the volume (Read-only, value type CFString) */
981 /* UbiquitousItem Properties */
984 const CFStringRef kCFURLIsUbiquitousItemKey
CF_AVAILABLE(10_7
, 5_0
);
985 /* true if this item is synced to the cloud, false if it is only a local file. (Read-only, value type CFBoolean) */
988 const CFStringRef kCFURLUbiquitousItemHasUnresolvedConflictsKey
CF_AVAILABLE(10_7
, 5_0
);
989 /* true if this item has conflicts outstanding. (Read-only, value type CFBoolean) */
992 const CFStringRef kCFURLUbiquitousItemIsDownloadedKey
CF_AVAILABLE(10_7
, 5_0
);
993 /* true if there is local data present for this item. (Read-only, value type CFBoolean) */
996 const CFStringRef kCFURLUbiquitousItemIsDownloadingKey
CF_AVAILABLE(10_7
, 5_0
);
997 /* true if data is being downloaded for this item. (Read-only, value type CFBoolean) */
1000 const CFStringRef kCFURLUbiquitousItemIsUploadedKey
CF_AVAILABLE(10_7
, 5_0
);
1001 /* true if there is data present in the cloud for this item. (Read-only, value type CFBoolean) */
1004 const CFStringRef kCFURLUbiquitousItemIsUploadingKey
CF_AVAILABLE(10_7
, 5_0
);
1005 /* true if data is being uploaded for this item. (Read-only, value type CFBoolean) */
1008 const CFStringRef kCFURLUbiquitousItemPercentDownloadedKey
CF_DEPRECATED(10_7
, 10_8
, 5_0
, 6_0
);
1009 /* Use NSMetadataQuery and NSMetadataUbiquitousItemPercentDownloadedKey on NSMetadataItem instead */
1012 const CFStringRef kCFURLUbiquitousItemPercentUploadedKey
CF_DEPRECATED(10_7
, 10_8
, 5_0
, 6_0
);
1013 /* Use NSMetadataQuery and NSMetadataUbiquitousItemPercentUploadedKey on NSMetadataItem instead */
1015 typedef CF_OPTIONS(CFOptionFlags
, CFURLBookmarkCreationOptions
) {
1016 kCFURLBookmarkCreationPreferFileIDResolutionMask
= ( 1UL << 8 ), // At resolution time, this alias will prefer resolving by the embedded fileID to the path
1017 kCFURLBookmarkCreationMinimalBookmarkMask
= ( 1UL << 9 ), // Creates a bookmark with "less" information, which may be smaller but still be able to resolve in certain ways
1018 kCFURLBookmarkCreationSuitableForBookmarkFile
= ( 1UL << 10 ), // includes in the created bookmark those properties which are needed for a bookmark/alias file
1019 kCFURLBookmarkCreationWithSecurityScope
CF_ENUM_AVAILABLE(10_7
,NA
) = ( 1UL << 11 ), // Mac OS X 10.7.3 and later, include information in the bookmark data which allows the same sandboxed process to access the resource after being relaunched
1020 kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess
CF_ENUM_AVAILABLE(10_7
,NA
) = ( 1UL << 12 ), // Mac OS X 10.7.3 and later, if used with kCFURLBookmarkCreationWithSecurityScope, at resolution time only read access to the resource will be granted
1024 kCFBookmarkResolutionWithoutUIMask
= ( 1UL << 8 ), // don't perform any UI during bookmark resolution
1025 kCFBookmarkResolutionWithoutMountingMask
= ( 1UL << 9 ), // don't mount a volume during bookmark resolution
1029 kCFURLBookmarkResolutionWithSecurityScope
CF_ENUM_AVAILABLE(10_7
,NA
) = ( 1UL << 10 ), // Mac OS X 10.7.3 and later, extract the security scope included at creation time to provide the ability to access the resource.
1032 typedef CFOptionFlags CFURLBookmarkResolutionOptions
;
1034 typedef CFOptionFlags CFURLBookmarkFileCreationOptions
;
1036 CF_IMPLICIT_BRIDGING_DISABLED
1038 /* @function CFURLCreateBookmarkData
1039 @discussion Create a CFDataRef containing an externalizable representation from a CFURLRef, modified with the given options, including ( at the minimum ) any
1040 properties in the propertiesToInclude array which are retrievable from the given url.
1041 @param allocator the CFAllocator to use to create this object
1042 @param url the CFURLRef to create a bookmark data from.
1043 @param options a set of options which control creation of the bookmark data
1044 @param resourcePropertiesToInclude If non-NULL, an CFArrayRef of additional properties copied from the url to include in the created bookmark data.
1045 @param relativeToURL If non-NULL, the created bookmark will be relative to the given url. If kCFURLBookmarkCreationWithSecurityScope is given as
1046 an option and relativeToURL is non-NULL, then a collection-scoped bookmark is created which enables future access to url provided the caller has
1047 access to relativeURL.
1048 @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
1049 @result A CFDataRef containing an data, which can be later be passed to CFURLCreateByResolvingBookmarkData() or to CFURLCopyPropertiesForKeysFromBookmarkData() / CFURLCopyPropertyForKeyFromBookmarkData() */
1051 CFDataRef
CFURLCreateBookmarkData ( CFAllocatorRef allocator
, CFURLRef url
, CFURLBookmarkCreationOptions options
, CFArrayRef resourcePropertiesToInclude
, CFURLRef relativeToURL
, CFErrorRef
* error
) CF_AVAILABLE(10_6
, 4_0
);
1053 /* @function CFURLCreateByResolvingBookmarkData
1054 @discussion Given a CFDataRef created with CFURLCreateBookmarkRepresentation(), return a CFURLRef of the item it was a bookmark to, and
1055 attempt to pre-cache those properties in propertiesToInclude in the resulting url. If in the process of resolving the bookmark into the CFURLRef
1056 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,
1057 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
1058 item cannot be found, return NULL. A bookmark created with security scope may fail to resolve if the caller does not have the same code signing identity
1059 as the caller which created the bookmark.
1060 After resolving a security scoped bookmark, the caller must call CFURLStartAccessingSecurityScopedResource() in order to gain access to the resource.
1061 If an error ( other than "original item can not be found" ) occurs during the process, return NULL and fill in error )
1062 @param allocator the CFAllocator to use to create this object
1063 @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData
1064 @param options options which affect the resolution
1065 @param relativeToURL If non-NULL, and if the bookmark was created relative to another url, then resolve it relative to this url. If
1066 kCFURLBookmarkCreationWithSecurityScope was provided at creation, and kCFURLBookmarkResolutionWithSecurityScope is set, then relativeURL
1067 should point to the same item which was passed as relavitiveURL at creation time.
1068 @param resourcePropertiesToInclude If non-NULL, a CFArray containing those properties which the caller would like to already be cached on the given url
1069 @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
1070 corresponding properties on the returned file. Clients, upon seeing a stale representation, may want to replace whatever stored bookmark data they
1071 have saved and create a new one.
1072 @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
1073 @result A CFURLRef of a file which is the closest match to the file the bookmark data */
1075 CFURLRef
CFURLCreateByResolvingBookmarkData ( CFAllocatorRef allocator
, CFDataRef bookmark
, CFURLBookmarkResolutionOptions options
, CFURLRef relativeToURL
, CFArrayRef resourcePropertiesToInclude
, Boolean
* isStale
, CFErrorRef
* error
) CF_AVAILABLE(10_6
, 4_0
);
1077 /* @function CFURLCreatePropertiesForKeysFromBookmarkData
1078 @discussion Given a bookmark, return a dictionary of properties ( all properties if propertiesToReturn == NULL ).
1079 This returns only the properties stored within the bookmark and will not attempt to resolve the bookmark or do i/o.
1080 @param allocator the CFAllocator to use to create this object
1081 @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData
1082 @param propertiesToReturn a CFArrayRef of the properties of the bookmark data which the client would like returned.
1083 @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 ) */
1085 CFDictionaryRef
CFURLCreateResourcePropertiesForKeysFromBookmarkData ( CFAllocatorRef allocator
, CFArrayRef resourcePropertiesToReturn
, CFDataRef bookmark
) CF_AVAILABLE(10_6
, 4_0
);
1087 /* @function CFURLCreatePropertyForKeyFromBookmarkData
1088 @discussion Given a bookmark, return the value for a given property from the bookmark data
1089 This returns only the properties stored within the bookmark and will not attempt to resolve the bookmark or do i/o.
1090 @param allocator the CFAllocator to use to create this object
1091 @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData
1092 @param propertyKey the property key to return.
1093 @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 ) */
1095 CFTypeRef
CFURLCreateResourcePropertyForKeyFromBookmarkData( CFAllocatorRef allocator
, CFStringRef resourcePropertyKey
, CFDataRef bookmark
) CF_AVAILABLE(10_6
, 4_0
);
1097 /*! @function CFURLCreateBookmarkDataFromFile
1098 @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
1099 created before SnowLeopard which contains Alias Manager information and no bookmark data, then a CFDataRef will be synthesized which contains
1100 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
1101 if it is corrupt, NULL will be returned and error will be filled in if errorRef is non-NULL.
1102 @param allocator the CFAllocator to use to create this object
1103 @param fileURL a CFURLRef to to the alias file to create the bookmark data from
1104 @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
1105 @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.
1108 CFDataRef
CFURLCreateBookmarkDataFromFile(CFAllocatorRef allocator
, CFURLRef fileURL
, CFErrorRef
*errorRef
) CF_AVAILABLE(10_6
, 5_0
);
1110 /*! @function CFURLWriteBookmarkDataToFile
1111 @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
1112 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
1113 .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
1114 systems running something before SnowLeopard to resolve this file using Alias Manager routines and get back the same file as the bookmark routines.
1115 The bookmark data must have been created with the kCFURLBookmarkCreationSuitableForBookmarkFile option and an error will be returned if not.
1116 @param allocator the CFAllocator to use to create this object
1117 @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData
1118 @param options options flags
1119 @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
1122 Boolean
CFURLWriteBookmarkDataToFile( CFDataRef bookmarkRef
, CFURLRef fileURL
, CFURLBookmarkFileCreationOptions options
, CFErrorRef
*errorRef
) CF_AVAILABLE(10_6
, 5_0
);
1124 /*! @function CFURLCreateBookmarkDataFromAliasRecord
1125 @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.
1126 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
1127 CFURLCreateResourcePropertiesForKeysFromBookmarkData() / CFURLCreateResourcePropertyForKeyFromBookmarkData().
1128 @param allocator the CFAllocator to use to create this object
1129 @param aliasRecordDataRef the contents of an AliasRecord to create bookmark data for
1130 @result A CFDataRef containing an data, which can be later be passed to CFURLCreateByResolvingBookmarkData() or to CFURLCopyPropertiesForKeysFromBookmarkData() / CFURLCopyPropertyForKeyFromBookmarkData()
1133 CFDataRef
CFURLCreateBookmarkDataFromAliasRecord ( CFAllocatorRef allocatorRef
, CFDataRef aliasRecordDataRef
) CF_AVAILABLE_MAC(10_6
);
1135 CF_IMPLICIT_BRIDGING_ENABLED
1137 /*! @function CFURLStartAccessingSecurityScopedResource
1138 @discussion Given a CFURLRef created by resolving a bookmark data created with security scope, make the resource referenced by the
1139 url accessible to the process. When access to this resource is no longer needed the client should call
1140 CFURLStopAccessingSecurityScopedResource(). Each call to CFURLStartAccessingSecurityScopedResource() must be balanced
1141 with a call to CFURLStopAccessingSecurityScopedResource().
1142 @param url the CFURLRef for the resource returned by CFURLCreateByResolvingBookmarkData() using kCFURLBookmarkResolutionWithSecurityScope.
1143 @result returns TRUE if access was granted and FALSE if the url does not reference a security scoped resource, or if some error occurred
1144 which didn't allow access to be granted
1147 Boolean
CFURLStartAccessingSecurityScopedResource(CFURLRef url
) CF_AVAILABLE(10_7
, NA
); // Available in MacOS X 10.7.3 and later
1149 /*! @function CFURLStopAccessingSecurityScopedResource
1150 @discussion Revokes the access granted to the url by a prior successful call to CFURLStartAccessingSecurityScopedResource().
1151 @param url the CFURLRef for the resource to stop accessing.
1154 void CFURLStopAccessingSecurityScopedResource(CFURLRef url
) CF_AVAILABLE(10_7
, NA
);
1156 #endif /* TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE */
1159 CF_IMPLICIT_BRIDGING_DISABLED
1161 #endif /* ! __COREFOUNDATION_CFURL__ */