]> git.saurik.com Git - apple/cf.git/blob - CFURL.h
CF-635.15.tar.gz
[apple/cf.git] / CFURL.h
1 /*
2 * Copyright (c) 2011 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /* CFURL.h
25 Copyright (c) 1998-2011, Apple Inc. All rights reserved.
26 */
27
28 #if !defined(__COREFOUNDATION_CFURL__)
29 #define __COREFOUNDATION_CFURL__ 1
30
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>
36
37 CF_EXTERN_C_BEGIN
38
39 enum {
40 kCFURLPOSIXPathStyle = 0,
41 kCFURLHFSPathStyle,
42 kCFURLWindowsPathStyle
43 };
44 typedef CFIndex CFURLPathStyle;
45
46 typedef const struct __CFURL * CFURLRef;
47
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. */
61
62 CF_EXPORT
63 CFTypeID CFURLGetTypeID(void);
64
65 /* encoding will be used both to interpret the bytes of URLBytes, and to */
66 /* interpret any percent-escapes within the bytes. */
67 CF_EXPORT
68 CFURLRef CFURLCreateWithBytes(CFAllocatorRef allocator, const UInt8 *URLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL);
69
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) */
74 CF_EXPORT
75 CFDataRef CFURLCreateData(CFAllocatorRef allocator, CFURLRef url, CFStringEncoding encoding, Boolean escapeWhitespace);
76
77 /* Any escape sequences in URLString will be interpreted via UTF-8. */
78 CF_EXPORT
79 CFURLRef CFURLCreateWithString(CFAllocatorRef allocator, CFStringRef URLString, CFURLRef baseURL);
80
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 */
92 CF_EXPORT
93 CFURLRef CFURLCreateAbsoluteURLWithBytes(CFAllocatorRef alloc, const UInt8 *relativeURLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL, Boolean useCompatibilityMode);
94
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 */
100 /* components */
101 CF_EXPORT
102 CFURLRef CFURLCreateWithFileSystemPath(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory);
103
104 CF_EXPORT
105 CFURLRef CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory);
106
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 */
112 /* is ignored. */
113 CF_EXPORT
114 CFURLRef CFURLCreateWithFileSystemPathRelativeToBase(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL);
115
116 CF_EXPORT
117 CFURLRef CFURLCreateFromFileSystemRepresentationRelativeToBase(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory, CFURLRef baseURL);
118
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. */
126 CF_EXPORT
127 Boolean CFURLGetFileSystemRepresentation(CFURLRef url, Boolean resolveAgainstBase, UInt8 *buffer, CFIndex maxBufLen);
128
129 /* Creates a new URL by resolving the relative portion of relativeURL against its base. */
130 CF_EXPORT
131 CFURLRef CFURLCopyAbsoluteURL(CFURLRef relativeURL);
132
133 /* Returns the URL's string. */
134 CF_EXPORT
135 CFStringRef CFURLGetString(CFURLRef anURL);
136
137 /* Returns the base URL if it exists */
138 CF_EXPORT
139 CFURLRef CFURLGetBaseURL(CFURLRef anURL);
140
141 /*
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
159
160 <scheme> "://" <net location> <path, always starting with slash> <add'l resource specifiers>
161
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.
175
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.
178
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
191
192 CFStringRef myParams = CFURLCopyParameters(ftpURL, CFSTR("=;%"));
193
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.
198 */
199
200 /* Returns true if anURL conforms to RFC 1808 */
201 CF_EXPORT
202 Boolean CFURLCanBeDecomposed(CFURLRef anURL);
203
204 /* The next several methods leave any percent escape sequences intact */
205
206 CF_EXPORT
207 CFStringRef CFURLCopyScheme(CFURLRef anURL);
208
209 /* NULL if CFURLCanBeDecomposed(anURL) is false */
210 CF_EXPORT
211 CFStringRef CFURLCopyNetLocation(CFURLRef anURL);
212
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. */
220
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. */
224 CF_EXPORT
225 CFStringRef CFURLCopyPath(CFURLRef anURL);
226
227 CF_EXPORT
228 CFStringRef CFURLCopyStrictPath(CFURLRef anURL, Boolean *isAbsolute);
229
230 CF_EXPORT
231 CFStringRef CFURLCopyFileSystemPath(CFURLRef anURL, CFURLPathStyle pathStyle);
232
233 /* Returns whether anURL's path represents a directory */
234 /* (true returned) or a simple file (false returned) */
235 CF_EXPORT
236 Boolean CFURLHasDirectoryPath(CFURLRef anURL);
237
238 /* Any additional resource specifiers after the path. For URLs */
239 /* that cannot be decomposed, this is everything except the scheme itself. */
240 CF_EXPORT
241 CFStringRef CFURLCopyResourceSpecifier(CFURLRef anURL);
242
243 CF_EXPORT
244 CFStringRef CFURLCopyHostName(CFURLRef anURL);
245
246 CF_EXPORT
247 SInt32 CFURLGetPortNumber(CFURLRef anURL); /* Returns -1 if no port number is specified */
248
249 CF_EXPORT
250 CFStringRef CFURLCopyUserName(CFURLRef anURL);
251
252 CF_EXPORT
253 CFStringRef CFURLCopyPassword(CFURLRef anURL);
254
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 */
260 CF_EXPORT
261 CFStringRef CFURLCopyParameterString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped);
262
263 CF_EXPORT
264 CFStringRef CFURLCopyQueryString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped);
265
266 CF_EXPORT
267 CFStringRef CFURLCopyFragment(CFURLRef anURL, CFStringRef charactersToLeaveEscaped);
268
269 CF_EXPORT
270 CFStringRef CFURLCopyLastPathComponent(CFURLRef url);
271
272 CF_EXPORT
273 CFStringRef CFURLCopyPathExtension(CFURLRef url);
274
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. */
278
279 CF_EXPORT
280 CFURLRef CFURLCreateCopyAppendingPathComponent(CFAllocatorRef allocator, CFURLRef url, CFStringRef pathComponent, Boolean isDirectory);
281
282 CF_EXPORT
283 CFURLRef CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator, CFURLRef url);
284
285 CF_EXPORT
286 CFURLRef CFURLCreateCopyAppendingPathExtension(CFAllocatorRef allocator, CFURLRef url, CFStringRef extension);
287
288 CF_EXPORT
289 CFURLRef CFURLCreateCopyDeletingPathExtension(CFAllocatorRef allocator, CFURLRef url);
290
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 */
297 CF_EXPORT
298 CFIndex CFURLGetBytes(CFURLRef url, UInt8 *buffer, CFIndex bufferLength);
299
300 enum {
301 kCFURLComponentScheme = 1,
302 kCFURLComponentNetLocation = 2,
303 kCFURLComponentPath = 3,
304 kCFURLComponentResourceSpecifier = 4,
305
306 kCFURLComponentUser = 5,
307 kCFURLComponentPassword = 6,
308 kCFURLComponentUserInfo = 7,
309 kCFURLComponentHost = 8,
310 kCFURLComponentPort = 9,
311 kCFURLComponentParameterString = 10,
312 kCFURLComponentQuery = 11,
313 kCFURLComponentFragment = 12
314 };
315 typedef CFIndex CFURLComponentType;
316
317 /*
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!
321
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 -
329
330 For the URL http://www.apple.com/hotnews/
331
332 Component returned range rangeIncludingSeparators
333 scheme (0, 4) (0, 7)
334 net location (7, 13) (4, 16)
335 path (20, 9) (20, 9)
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)
340 host (7, 13) (4, 16)
341 port (kCFNotFound, 0) (20, 0)
342 parameter (kCFNotFound, 0) (29, 0)
343 query (kCFNotFound, 0) (29, 0)
344 fragment (kCFNotFound, 0) (29, 0)
345
346
347 For the URL ./relPath/file.html#fragment
348
349 Component returned range rangeIncludingSeparators
350 scheme (kCFNotFound, 0) (0, 0)
351 net location (kCFNotFound, 0) (0, 0)
352 path (0, 19) (0, 20)
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)
362
363
364 For the URL scheme://user:pass@host:1/path/path2/file.html;params?query#fragment
365
366 Component returned range rangeIncludingSeparators
367 scheme (0, 6) (0, 9)
368 net location (9, 16) (6, 19)
369 path (25, 21) (25, 22)
370 resource specifier (47, 21) (46, 22)
371 user (9, 4) (6, 8)
372 password (14, 4) (13, 6)
373 user info (9, 9) (6, 13)
374 host (19, 4) (18, 6)
375 port (24, 1) (23, 2)
376 parameter (47, 6) (46, 8)
377 query (54, 5) (53, 7)
378 fragment (60, 8) (59, 9)
379 */
380 CF_EXPORT
381 CFRange CFURLGetByteRangeForComponent(CFURLRef url, CFURLComponentType component, CFRange *rangeIncludingSeparators);
382
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. */
390 CF_EXPORT
391 CFStringRef CFURLCreateStringByReplacingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveEscaped);
392
393 /* As above, but allows you to specify the encoding to use when interpreting percent escapes */
394 CF_EXPORT
395 CFStringRef CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFAllocatorRef allocator, CFStringRef origString, CFStringRef charsToLeaveEscaped, CFStringEncoding encoding);
396
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: */
408
409 /* newString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, origString, NULL, NULL, kCFStringEncodingUTF8); */
410 CF_EXPORT
411 CFStringRef CFURLCreateStringByAddingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding);
412
413
414 #if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION
415
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. */
421 CF_EXPORT
422 CFURLRef CFURLCreateFileReferenceURL(CFAllocatorRef allocator, CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
423
424
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. */
430 CF_EXPORT
431 CFURLRef CFURLCreateFilePathURL(CFAllocatorRef allocator, CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
432
433 #endif
434
435
436
437 #if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION
438
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.
443
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.
447
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.
450 */
451
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. */
459 CF_EXPORT
460 Boolean CFURLCopyResourcePropertyForKey(CFURLRef url, CFStringRef key, void *propertyValueTypeRefPtr, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
461
462
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. */
470 CF_EXPORT
471 CFDictionaryRef CFURLCopyResourcePropertiesForKeys(CFURLRef url, CFArrayRef keys, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
472
473
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. */
481 CF_EXPORT
482 Boolean CFURLSetResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
483
484
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. */
493 CF_EXPORT
494 Boolean CFURLSetResourcePropertiesForKeys(CFURLRef url, CFDictionaryRef keyedPropertyValues, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
495
496
497 CF_EXPORT
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. */
500
501
502 /* Discards a cached property value for a specific key */
503 CF_EXPORT
504 void CFURLClearResourcePropertyCacheForKey(CFURLRef url, CFStringRef key) CF_AVAILABLE(10_6, 4_0);
505
506
507 /* Discards all cached property values */
508 CF_EXPORT
509 void CFURLClearResourcePropertyCache(CFURLRef url) CF_AVAILABLE(10_6, 4_0);
510
511
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. */
517 CF_EXPORT
518 void CFURLSetTemporaryResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue) CF_AVAILABLE(10_6, 4_0);
519
520
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. */
530 CF_EXPORT
531 Boolean CFURLResourceIsReachable(CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
532
533
534 /* Properties of File System Resources */
535
536 CF_EXPORT
537 const CFStringRef kCFURLNameKey CF_AVAILABLE(10_6, 4_0);
538 /* The resource name provided by the file system (value type CFString) */
539
540 CF_EXPORT
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) */
543
544 CF_EXPORT
545 const CFStringRef kCFURLIsRegularFileKey CF_AVAILABLE(10_6, 4_0);
546 /* True for regular files (Read-only, value type CFBoolean) */
547
548 CF_EXPORT
549 const CFStringRef kCFURLIsDirectoryKey CF_AVAILABLE(10_6, 4_0);
550 /* True for directories (Read-only, CFBoolean) */
551
552 CF_EXPORT
553 const CFStringRef kCFURLIsSymbolicLinkKey CF_AVAILABLE(10_6, 4_0);
554 /* True for symlinks (Read-only, value type CFBoolean) */
555
556 CF_EXPORT
557 const CFStringRef kCFURLIsVolumeKey CF_AVAILABLE(10_6, 4_0);
558 /* True for the root directory of a volume (Read-only, value type CFBoolean) */
559
560 CF_EXPORT
561 const CFStringRef kCFURLIsPackageKey CF_AVAILABLE(10_6, 4_0);
562 /* True for packaged directories (value type CFBoolean) */
563
564 CF_EXPORT
565 const CFStringRef kCFURLIsSystemImmutableKey CF_AVAILABLE(10_6, 4_0);
566 /* True for system-immutable resources (value type CFBoolean) */
567
568 CF_EXPORT
569 const CFStringRef kCFURLIsUserImmutableKey CF_AVAILABLE(10_6, 4_0);
570 /* True for user-immutable resources (value type CFBoolean) */
571
572 CF_EXPORT
573 const CFStringRef kCFURLIsHiddenKey CF_AVAILABLE(10_6, 4_0);
574 /* True for resources normally hidden from users (value type CFBoolean) */
575
576 CF_EXPORT
577 const CFStringRef kCFURLHasHiddenExtensionKey CF_AVAILABLE(10_6, 4_0);
578 /* True for resources whose filename extension is hidden (value type CFBoolean) */
579
580 CF_EXPORT
581 const CFStringRef kCFURLCreationDateKey CF_AVAILABLE(10_6, 4_0);
582 /* The date the resource was created (value type CFDate) */
583
584 CF_EXPORT
585 const CFStringRef kCFURLContentAccessDateKey CF_AVAILABLE(10_6, 4_0);
586 /* The date the resource was last accessed (Read-only, value type CFDate) */
587
588 CF_EXPORT
589 const CFStringRef kCFURLContentModificationDateKey CF_AVAILABLE(10_6, 4_0);
590 /* The time the resource content was last modified (value type CFDate) */
591
592 CF_EXPORT
593 const CFStringRef kCFURLAttributeModificationDateKey CF_AVAILABLE(10_6, 4_0);
594 /* The time the resource's attributes were last modified (value type CFDate) */
595
596 CF_EXPORT
597 const CFStringRef kCFURLLinkCountKey CF_AVAILABLE(10_6, 4_0);
598 /* Number of hard links to the resource (Read-only, CFNumber) */
599
600 CF_EXPORT
601 const CFStringRef kCFURLParentDirectoryURLKey CF_AVAILABLE(10_6, 4_0);
602 /* URL of the parent directory, if any (Read-only, value type CFURL) */
603
604 CF_EXPORT
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) */
607
608 CF_EXPORT
609 const CFStringRef kCFURLTypeIdentifierKey CF_AVAILABLE(10_6, 4_0);
610 /* Uniform type identifier for the resource (Read-only, value type CFString) */
611
612 CF_EXPORT
613 const CFStringRef kCFURLLocalizedTypeDescriptionKey CF_AVAILABLE(10_6, 4_0);
614 /* User-visible type or "kind" descriptiopn (Read-only, value type CFString) */
615
616 CF_EXPORT
617 const CFStringRef kCFURLLabelNumberKey CF_AVAILABLE(10_6, 4_0);
618 /* The label number assigned to the resource (value type CFNumber) */
619
620 CF_EXPORT
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) */
623
624 CF_EXPORT
625 const CFStringRef kCFURLLocalizedLabelKey CF_AVAILABLE(10_6, 4_0);
626 /* The user-visible label text (Read-only, value type CFString) */
627
628 CF_EXPORT
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) */
631
632 CF_EXPORT
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) */
635
636 CF_EXPORT
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) */
639
640 CF_EXPORT
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) */
643
644 CF_EXPORT
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) */
647
648 CF_EXPORT
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) */
651
652 CF_EXPORT
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) */
655
656 CF_EXPORT
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) */
659
660 CF_EXPORT
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) */
663
664 CF_EXPORT
665 const CFStringRef kCFURLFileResourceTypeKey CF_AVAILABLE(10_7, 5_0);
666 /* Returns the file system object type. (Read-only, value type CFString) */
667
668 /* The file system object type values returned for the kCFURLFileResourceTypeKey */
669 CF_EXPORT
670 const CFStringRef kCFURLFileResourceTypeNamedPipe CF_AVAILABLE(10_7, 5_0);
671 CF_EXPORT
672 const CFStringRef kCFURLFileResourceTypeCharacterSpecial CF_AVAILABLE(10_7, 5_0);
673 CF_EXPORT
674 const CFStringRef kCFURLFileResourceTypeDirectory CF_AVAILABLE(10_7, 5_0);
675 CF_EXPORT
676 const CFStringRef kCFURLFileResourceTypeBlockSpecial CF_AVAILABLE(10_7, 5_0);
677 CF_EXPORT
678 const CFStringRef kCFURLFileResourceTypeRegular CF_AVAILABLE(10_7, 5_0);
679 CF_EXPORT
680 const CFStringRef kCFURLFileResourceTypeSymbolicLink CF_AVAILABLE(10_7, 5_0);
681 CF_EXPORT
682 const CFStringRef kCFURLFileResourceTypeSocket CF_AVAILABLE(10_7, 5_0);
683 CF_EXPORT
684 const CFStringRef kCFURLFileResourceTypeUnknown CF_AVAILABLE(10_7, 5_0);
685
686 /* File Properties */
687
688 CF_EXPORT
689 const CFStringRef kCFURLFileSizeKey CF_AVAILABLE(10_6, 4_0);
690 /* Total file size, in bytes (Read-only, value type CFNumber) */
691
692 CF_EXPORT
693 const CFStringRef kCFURLFileAllocatedSizeKey CF_AVAILABLE(10_6, 4_0);
694 /* Total size of blocks allocated (Read-only, value type CFNumber) */
695
696 CF_EXPORT
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) */
699
700 CF_EXPORT
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) */
703
704 CF_EXPORT
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) */
707
708 CF_EXPORT
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) */
711
712
713 /* Volume Properties */
714
715 /* For convenience, volume properties may be requested from any resource on a volume. */
716
717 CF_EXPORT
718 const CFStringRef kCFURLVolumeLocalizedFormatDescriptionKey CF_AVAILABLE(10_6, 4_0);
719 /* The user-visible volume format (Read-only, value type CFString) */
720
721 CF_EXPORT
722 const CFStringRef kCFURLVolumeTotalCapacityKey CF_AVAILABLE(10_6, 4_0);
723 /* Total volume capacity in bytes (Read-only, value type CFNumber) */
724
725 CF_EXPORT
726 const CFStringRef kCFURLVolumeAvailableCapacityKey CF_AVAILABLE(10_6, 4_0);
727 /* Total free space, in bytes (Read-only, value type CFNumber) */
728
729 CF_EXPORT
730 const CFStringRef kCFURLVolumeResourceCountKey CF_AVAILABLE(10_6, 4_0);
731 /* Total number of resources on the volume (Read-only, value type CFNumber) */
732
733 CF_EXPORT
734 const CFStringRef kCFURLVolumeSupportsPersistentIDsKey CF_AVAILABLE(10_6, 4_0);
735 /* Read-only, value type CFBoolean */
736
737 CF_EXPORT
738 const CFStringRef kCFURLVolumeSupportsSymbolicLinksKey CF_AVAILABLE(10_6, 4_0);
739 /* Read-only, value type CFBoolean */
740
741 CF_EXPORT
742 const CFStringRef kCFURLVolumeSupportsHardLinksKey CF_AVAILABLE(10_6, 4_0);
743 /* Read-only, value type CFBoolean */
744
745 CF_EXPORT
746 const CFStringRef kCFURLVolumeSupportsJournalingKey CF_AVAILABLE(10_6, 4_0);
747 /* Read-only, value type CFBoolean */
748
749 CF_EXPORT
750 const CFStringRef kCFURLVolumeIsJournalingKey CF_AVAILABLE(10_6, 4_0);
751 /* Read-only, value type CFBoolean */
752
753 CF_EXPORT
754 const CFStringRef kCFURLVolumeSupportsSparseFilesKey CF_AVAILABLE(10_6, 4_0);
755 /* Read-only, value type CFBoolean */
756
757 CF_EXPORT
758 const CFStringRef kCFURLVolumeSupportsZeroRunsKey CF_AVAILABLE(10_6, 4_0);
759 /* Read-only, value type CFBoolean */
760
761 CF_EXPORT
762 const CFStringRef kCFURLVolumeSupportsCaseSensitiveNamesKey CF_AVAILABLE(10_6, 4_0);
763 /* Read-only, value type CFBoolean */
764
765 CF_EXPORT
766 const CFStringRef kCFURLVolumeSupportsCasePreservedNamesKey CF_AVAILABLE(10_6, 4_0);
767 /* Read-only, value type CFBoolean */
768
769 CF_EXPORT
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) */
772
773 CF_EXPORT
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) */
776
777 CF_EXPORT
778 const CFStringRef kCFURLVolumeSupportsRenamingKey CF_AVAILABLE(10_7, 5_0);
779 /* true if the volume can be renamed. (Read-only, value type CFBoolean) */
780
781 CF_EXPORT
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) */
784
785 CF_EXPORT
786 const CFStringRef kCFURLVolumeSupportsExtendedSecurityKey CF_AVAILABLE(10_7, 5_0);
787 /* true if the volume implements extended security (ACLs). (Read-only, value type CFBoolean) */
788
789 CF_EXPORT
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) */
792
793 CF_EXPORT
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) */
796
797 CF_EXPORT
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) */
800
801 CF_EXPORT
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) */
804
805 CF_EXPORT
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) */
808
809 CF_EXPORT
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) */
812
813 CF_EXPORT
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) */
816
817 CF_EXPORT
818 const CFStringRef kCFURLVolumeIsReadOnlyKey CF_AVAILABLE(10_7, 5_0);
819 /* true if the volume is read-only. (Read-only, value type CFBoolean) */
820
821 CF_EXPORT
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) */
824
825 CF_EXPORT
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) */
828
829 CF_EXPORT
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) */
832
833 CF_EXPORT
834 const CFStringRef kCFURLVolumeNameKey CF_AVAILABLE(10_7, 5_0);
835 /* The name of the volume (settable if kCFURLVolumeSupportsRenamingKey is true, value type CFString) */
836
837 CF_EXPORT
838 const CFStringRef kCFURLVolumeLocalizedNameKey CF_AVAILABLE(10_7, 5_0);
839 /* The user-presentable name of the volume (Read-only, value type CFString) */
840
841 /* UbiquitousItem Properties */
842
843 CF_EXPORT
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) */
846
847 CF_EXPORT
848 const CFStringRef kCFURLUbiquitousItemHasUnresolvedConflictsKey CF_AVAILABLE(10_7, 5_0);
849 /* true if this item has conflicts outstanding. (Read-only, value type CFBoolean) */
850
851 CF_EXPORT
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) */
854
855 CF_EXPORT
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) */
858
859 CF_EXPORT
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) */
862
863 CF_EXPORT
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) */
866
867 CF_EXPORT
868 const CFStringRef kCFURLUbiquitousItemPercentDownloadedKey CF_AVAILABLE(10_7, 5_0);
869 /* [0-100] percent of data downloaded. (Read-only, value type double CFNumber) */
870
871 CF_EXPORT
872 const CFStringRef kCFURLUbiquitousItemPercentUploadedKey CF_AVAILABLE(10_7, 5_0);
873 /* [0-100] percent of data downloaded. (Read-only, value type double CFNumber) */
874
875 enum {
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
879 };
880 typedef CFOptionFlags CFURLBookmarkCreationOptions;
881
882 enum {
883 kCFBookmarkResolutionWithoutUIMask = ( 1UL << 8 ), // don't perform any UI during bookmark resolution
884 kCFBookmarkResolutionWithoutMountingMask = ( 1UL << 9 ), // don't mount a volume during bookmark resolution
885 };
886 typedef CFOptionFlags CFURLBookmarkResolutionOptions;
887
888 typedef CFOptionFlags CFURLBookmarkFileCreationOptions;
889
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() */
900 CF_EXPORT
901 CFDataRef CFURLCreateBookmarkData ( CFAllocatorRef allocator, CFURLRef url, CFURLBookmarkCreationOptions options, CFArrayRef resourcePropertiesToInclude, CFURLRef relativeToURL, CFErrorRef* error ) CF_AVAILABLE(10_6, 4_0);
902
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 */
919 CF_EXPORT
920 CFURLRef CFURLCreateByResolvingBookmarkData ( CFAllocatorRef allocator, CFDataRef bookmark, CFURLBookmarkResolutionOptions options, CFURLRef relativeToURL, CFArrayRef resourcePropertiesToInclude, Boolean* isStale, CFErrorRef* error ) CF_AVAILABLE(10_6, 4_0);
921
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 ) */
929 CF_EXPORT
930 CFDictionaryRef CFURLCreateResourcePropertiesForKeysFromBookmarkData ( CFAllocatorRef allocator, CFArrayRef resourcePropertiesToReturn, CFDataRef bookmark ) CF_AVAILABLE(10_6, 4_0);
931
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 ) */
939 CF_EXPORT
940 CFTypeRef CFURLCreateResourcePropertyForKeyFromBookmarkData( CFAllocatorRef allocator, CFStringRef resourcePropertyKey, CFDataRef bookmark ) CF_AVAILABLE(10_6, 4_0);
941
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.
951 */
952 CF_EXPORT
953 CFDataRef CFURLCreateBookmarkDataFromFile(CFAllocatorRef allocator, CFURLRef fileURL, CFErrorRef *errorRef ) CF_AVAILABLE(10_6, 5_0);
954
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
965 */
966 CF_EXPORT
967 Boolean CFURLWriteBookmarkDataToFile( CFDataRef bookmarkRef, CFURLRef fileURL, CFURLBookmarkFileCreationOptions options, CFErrorRef *errorRef ) CF_AVAILABLE(10_6, 5_0);
968
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()
976 */
977 CF_EXPORT
978 CFDataRef CFURLCreateBookmarkDataFromAliasRecord ( CFAllocatorRef allocatorRef, CFDataRef aliasRecordDataRef ) CF_AVAILABLE_MAC(10_6);
979
980 #endif /* TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE */
981
982 CF_EXTERN_C_END
983
984 #endif /* ! __COREFOUNDATION_CFURL__ */
985