]> git.saurik.com Git - apple/cf.git/blame - CFURL.h
CF-635.15.tar.gz
[apple/cf.git] / CFURL.h
CommitLineData
9ce05555 1/*
8ca704e1 2 * Copyright (c) 2011 Apple Inc. All rights reserved.
9ce05555
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
9ce05555
A
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 */
f64f9b69 23
9ce05555 24/* CFURL.h
8ca704e1 25 Copyright (c) 1998-2011, Apple Inc. All rights reserved.
9ce05555
A
26*/
27
28#if !defined(__COREFOUNDATION_CFURL__)
29#define __COREFOUNDATION_CFURL__ 1
30
31#include <CoreFoundation/CFBase.h>
32#include <CoreFoundation/CFData.h>
cf7d2af9 33#include <CoreFoundation/CFError.h>
9ce05555 34#include <CoreFoundation/CFString.h>
8ca704e1 35#include <CoreFoundation/CFNumber.h>
9ce05555 36
bd5b749c 37CF_EXTERN_C_BEGIN
9ce05555 38
bd5b749c 39enum {
9ce05555
A
40 kCFURLPOSIXPathStyle = 0,
41 kCFURLHFSPathStyle,
42 kCFURLWindowsPathStyle
bd5b749c
A
43};
44typedef CFIndex CFURLPathStyle;
9ce05555
A
45
46typedef 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
62CF_EXPORT
63CFTypeID 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. */
67CF_EXPORT
68CFURLRef 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) */
74CF_EXPORT
75CFDataRef CFURLCreateData(CFAllocatorRef allocator, CFURLRef url, CFStringEncoding encoding, Boolean escapeWhitespace);
76
77/* Any escape sequences in URLString will be interpreted via UTF-8. */
78CF_EXPORT
79CFURLRef CFURLCreateWithString(CFAllocatorRef allocator, CFStringRef URLString, CFURLRef baseURL);
80
9ce05555
A
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 */
d8925383 92CF_EXPORT
8ca704e1 93CFURLRef CFURLCreateAbsoluteURLWithBytes(CFAllocatorRef alloc, const UInt8 *relativeURLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL, Boolean useCompatibilityMode);
9ce05555
A
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 */
101CF_EXPORT
102CFURLRef CFURLCreateWithFileSystemPath(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory);
103
104CF_EXPORT
105CFURLRef CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory);
106
cf7d2af9
A
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. */
9ce05555
A
113CF_EXPORT
114CFURLRef CFURLCreateWithFileSystemPathRelativeToBase(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL);
115
116CF_EXPORT
117CFURLRef 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. */
126CF_EXPORT
127Boolean 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. */
130CF_EXPORT
131CFURLRef CFURLCopyAbsoluteURL(CFURLRef relativeURL);
132
133/* Returns the URL's string. */
134CF_EXPORT
135CFStringRef CFURLGetString(CFURLRef anURL);
136
137/* Returns the base URL if it exists */
138CF_EXPORT
139CFURLRef CFURLGetBaseURL(CFURLRef anURL);
140
141/*
142All URLs can be broken into two pieces - the scheme (preceding the
143first colon) and the resource specifier (following the first colon).
144Most URLs are also "standard" URLs conforming to RFC 1808 (available
145from www.w3c.org). This category includes URLs of the file, http,
146https, and ftp schemes, to name a few. Standard URLs start the
147resource specifier with two slashes ("//"), and can be broken into
148four distinct pieces - the scheme, the net location, the path, and
149further resource specifiers (typically an optional parameter, query,
150and/or fragment). The net location appears immediately following
151the two slashes and goes up to the next slash; it's format is
152scheme-specific, but is usually composed of some or all of a username,
153password, host name, and port. The path is a series of path components
154separated by slashes; if the net location is present, the path always
155begins with a slash. Standard URLs can be relative to another URL,
156in which case at least the scheme and possibly other pieces as well
157come from the base URL (see RFC 1808 for precise details when resolving
158a 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
162If a given CFURL can be decomposed (that is, conforms to RFC 1808), you
163can ask for each of the four basic pieces (scheme, net location, path,
164and resource specifer) separately, as well as for its base URL. The
165basic pieces are returned with any percent escape sequences still in
166place (although note that the scheme may not legally include any
167percent escapes); this is to allow the caller to distinguish between
168percent sequences that may have syntactic meaning if replaced by the
169character being escaped (for instance, a '/' in a path component).
170Since only the individual schemes know which characters are
171syntactically significant, CFURL cannot safely replace any percent
172escape sequences. However, you can use
173CFURLCreateStringByReplacingPercentEscapes() to create a new string with
174the percent escapes removed; see below.
175
176If a given CFURL can not be decomposed, you can ask for its scheme and its
177resource specifier; asking it for its net location or path will return NULL.
178
179To get more refined information about the components of a decomposable
180CFURL, you may ask for more specific pieces of the URL, expressed with
181the percent escapes removed. The available functions are CFURLCopyHostName(),
182CFURLGetPortNumber() (returns an Int32), CFURLCopyUserName(),
183CFURLCopyPassword(), CFURLCopyQuery(), CFURLCopyParameters(), and
184CFURLCopyFragment(). Because the parameters, query, and fragment of an
185URL may contain scheme-specific syntaxes, these methods take a second
186argument, giving a list of characters which should NOT be replaced if
187percent escaped. For instance, the ftp parameter syntax gives simple
188key-value pairs as "<key>=<value>;" Clearly if a key or value includes
189either '=' or ';', it must be escaped to avoid corrupting the meaning of
190the parameters, so the caller may request the parameter string as
191
192CFStringRef myParams = CFURLCopyParameters(ftpURL, CFSTR("=;%"));
193
194requesting that all percent escape sequences be replaced by the represented
195characters, except for escaped '=', '%' or ';' characters. Pass the empty
196string (CFSTR("")) to request that all percent escapes be replaced, or NULL
197to request that none be.
198*/
199
200/* Returns true if anURL conforms to RFC 1808 */
201CF_EXPORT
202Boolean CFURLCanBeDecomposed(CFURLRef anURL);
203
204/* The next several methods leave any percent escape sequences intact */
205
206CF_EXPORT
207CFStringRef CFURLCopyScheme(CFURLRef anURL);
208
209/* NULL if CFURLCanBeDecomposed(anURL) is false */
210CF_EXPORT
211CFStringRef 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. */
224CF_EXPORT
225CFStringRef CFURLCopyPath(CFURLRef anURL);
226
227CF_EXPORT
228CFStringRef CFURLCopyStrictPath(CFURLRef anURL, Boolean *isAbsolute);
229
230CF_EXPORT
231CFStringRef CFURLCopyFileSystemPath(CFURLRef anURL, CFURLPathStyle pathStyle);
232
233/* Returns whether anURL's path represents a directory */
234/* (true returned) or a simple file (false returned) */
235CF_EXPORT
236Boolean 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. */
240CF_EXPORT
241CFStringRef CFURLCopyResourceSpecifier(CFURLRef anURL);
242
243CF_EXPORT
244CFStringRef CFURLCopyHostName(CFURLRef anURL);
245
246CF_EXPORT
247SInt32 CFURLGetPortNumber(CFURLRef anURL); /* Returns -1 if no port number is specified */
248
249CF_EXPORT
250CFStringRef CFURLCopyUserName(CFURLRef anURL);
251
252CF_EXPORT
253CFStringRef 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 */
260CF_EXPORT
261CFStringRef CFURLCopyParameterString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped);
262
263CF_EXPORT
264CFStringRef CFURLCopyQueryString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped);
265
266CF_EXPORT
267CFStringRef CFURLCopyFragment(CFURLRef anURL, CFStringRef charactersToLeaveEscaped);
268
269CF_EXPORT
270CFStringRef CFURLCopyLastPathComponent(CFURLRef url);
271
272CF_EXPORT
273CFStringRef 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
279CF_EXPORT
280CFURLRef CFURLCreateCopyAppendingPathComponent(CFAllocatorRef allocator, CFURLRef url, CFStringRef pathComponent, Boolean isDirectory);
281
282CF_EXPORT
283CFURLRef CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator, CFURLRef url);
284
285CF_EXPORT
286CFURLRef CFURLCreateCopyAppendingPathExtension(CFAllocatorRef allocator, CFURLRef url, CFStringRef extension);
287
288CF_EXPORT
289CFURLRef CFURLCreateCopyDeletingPathExtension(CFAllocatorRef allocator, CFURLRef url);
290
9ce05555
A
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 */
d8925383 297CF_EXPORT
8ca704e1 298CFIndex CFURLGetBytes(CFURLRef url, UInt8 *buffer, CFIndex bufferLength);
9ce05555 299
bd5b749c 300enum {
9ce05555
A
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
bd5b749c
A
314};
315typedef CFIndex CFURLComponentType;
9ce05555
A
316
317/*
318Gets the range of the requested component in the bytes of url, as
319returned by CFURLGetBytes(). This range is only good for use in the
320bytes returned by CFURLGetBytes!
321
322If non-NULL, rangeIncludingSeparators gives the range of component
323including the sequences that separate component from the previous and
324next components. If there is no previous or next component, that end of
325rangeIncludingSeparators will match the range of the component itself.
326If url does not contain the given component type, (kCFNotFound, 0) is
327returned, and rangeIncludingSeparators is set to the location where the
328component would be inserted. Some examples -
329
330For the URL http://www.apple.com/hotnews/
331
332Component returned range rangeIncludingSeparators
333scheme (0, 4) (0, 7)
334net location (7, 13) (4, 16)
335path (20, 9) (20, 9)
336resource specifier (kCFNotFound, 0) (29, 0)
337user (kCFNotFound, 0) (7, 0)
338password (kCFNotFound, 0) (7, 0)
339user info (kCFNotFound, 0) (7, 0)
340host (7, 13) (4, 16)
341port (kCFNotFound, 0) (20, 0)
342parameter (kCFNotFound, 0) (29, 0)
343query (kCFNotFound, 0) (29, 0)
344fragment (kCFNotFound, 0) (29, 0)
345
346
347For the URL ./relPath/file.html#fragment
348
349Component returned range rangeIncludingSeparators
350scheme (kCFNotFound, 0) (0, 0)
351net location (kCFNotFound, 0) (0, 0)
352path (0, 19) (0, 20)
353resource specifier (20, 8) (19, 9)
354user (kCFNotFound, 0) (0, 0)
355password (kCFNotFound, 0) (0, 0)
356user info (kCFNotFound, 0) (0, 0)
357host (kCFNotFound, 0) (0, 0)
358port (kCFNotFound, 0) (0, 0)
359parameter (kCFNotFound, 0) (19, 0)
360query (kCFNotFound, 0) (19, 0)
361fragment (20, 8) (19, 9)
362
363
364For the URL scheme://user:pass@host:1/path/path2/file.html;params?query#fragment
365
366Component returned range rangeIncludingSeparators
367scheme (0, 6) (0, 9)
368net location (9, 16) (6, 19)
369path (25, 21) (25, 22)
370resource specifier (47, 21) (46, 22)
371user (9, 4) (6, 8)
372password (14, 4) (13, 6)
373user info (9, 9) (6, 13)
374host (19, 4) (18, 6)
375port (24, 1) (23, 2)
376parameter (47, 6) (46, 8)
377query (54, 5) (53, 7)
378fragment (60, 8) (59, 9)
379*/
d8925383 380CF_EXPORT
8ca704e1 381CFRange CFURLGetByteRangeForComponent(CFURLRef url, CFURLComponentType component, CFRange *rangeIncludingSeparators);
9ce05555
A
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. */
390CF_EXPORT
391CFStringRef CFURLCreateStringByReplacingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveEscaped);
392
9ce05555
A
393/* As above, but allows you to specify the encoding to use when interpreting percent escapes */
394CF_EXPORT
8ca704e1 395CFStringRef CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFAllocatorRef allocator, CFStringRef origString, CFStringRef charsToLeaveEscaped, CFStringEncoding encoding);
9ce05555
A
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
bd5b749c 409/* newString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, origString, NULL, NULL, kCFStringEncodingUTF8); */
9ce05555
A
410CF_EXPORT
411CFStringRef CFURLCreateStringByAddingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding);
412
413
8ca704e1
A
414#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION
415
cf7d2af9
A
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. */
421CF_EXPORT
8ca704e1 422CFURLRef CFURLCreateFileReferenceURL(CFAllocatorRef allocator, CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
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. */
430CF_EXPORT
8ca704e1 431CFURLRef CFURLCreateFilePathURL(CFAllocatorRef allocator, CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
cf7d2af9 432
8ca704e1 433#endif
cf7d2af9
A
434
435
436
8ca704e1 437#if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION
cf7d2af9
A
438
439/* The following APIs provide efficient access to resource properties. Properties
440are identified by keys, and values are represented as Core Foundation objects. The
441type of each value is fixed for each property, e.g. the modification date is a CFDateRef,
442the file size is a CFNumberRef.
443
444Values are fetched on-demand, synchronously, from the resource's backing store. They
445are cached and reused when fetched again through the same URL instance, until the
446client clears the value. The client has complete control over the cache lifetime.
447
448Some resource property values can be changed, given sufficient access permission to the resource.
449When 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. */
459CF_EXPORT
8ca704e1 460Boolean CFURLCopyResourcePropertyForKey(CFURLRef url, CFStringRef key, void *propertyValueTypeRefPtr, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
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. */
470CF_EXPORT
8ca704e1 471CFDictionaryRef CFURLCopyResourcePropertiesForKeys(CFURLRef url, CFArrayRef keys, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
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. */
481CF_EXPORT
8ca704e1 482Boolean CFURLSetResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
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 */
8ca704e1
A
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. */
cf7d2af9 493CF_EXPORT
8ca704e1
A
494Boolean CFURLSetResourcePropertiesForKeys(CFURLRef url, CFDictionaryRef keyedPropertyValues, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
495
496
497CF_EXPORT
498const 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. */
cf7d2af9
A
500
501
502/* Discards a cached property value for a specific key */
503CF_EXPORT
8ca704e1 504void CFURLClearResourcePropertyCacheForKey(CFURLRef url, CFStringRef key) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
505
506
507/* Discards all cached property values */
508CF_EXPORT
8ca704e1 509void CFURLClearResourcePropertyCache(CFURLRef url) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
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. */
517CF_EXPORT
8ca704e1 518void CFURLSetTemporaryResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
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. */
530CF_EXPORT
8ca704e1 531Boolean CFURLResourceIsReachable(CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
532
533
534/* Properties of File System Resources */
535
536CF_EXPORT
8ca704e1 537const CFStringRef kCFURLNameKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
538 /* The resource name provided by the file system (value type CFString) */
539
540CF_EXPORT
8ca704e1 541const CFStringRef kCFURLLocalizedNameKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
542 /* Localized or extension-hidden name as displayed to users (Read-only, value type CFString) */
543
544CF_EXPORT
8ca704e1 545const CFStringRef kCFURLIsRegularFileKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
546 /* True for regular files (Read-only, value type CFBoolean) */
547
548CF_EXPORT
8ca704e1 549const CFStringRef kCFURLIsDirectoryKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
550 /* True for directories (Read-only, CFBoolean) */
551
552CF_EXPORT
8ca704e1 553const CFStringRef kCFURLIsSymbolicLinkKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
554 /* True for symlinks (Read-only, value type CFBoolean) */
555
556CF_EXPORT
8ca704e1 557const CFStringRef kCFURLIsVolumeKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
558 /* True for the root directory of a volume (Read-only, value type CFBoolean) */
559
560CF_EXPORT
8ca704e1 561const CFStringRef kCFURLIsPackageKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
562 /* True for packaged directories (value type CFBoolean) */
563
564CF_EXPORT
8ca704e1 565const CFStringRef kCFURLIsSystemImmutableKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
566 /* True for system-immutable resources (value type CFBoolean) */
567
568CF_EXPORT
8ca704e1 569const CFStringRef kCFURLIsUserImmutableKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
570 /* True for user-immutable resources (value type CFBoolean) */
571
572CF_EXPORT
8ca704e1 573const CFStringRef kCFURLIsHiddenKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
574 /* True for resources normally hidden from users (value type CFBoolean) */
575
576CF_EXPORT
8ca704e1
A
577const CFStringRef kCFURLHasHiddenExtensionKey CF_AVAILABLE(10_6, 4_0);
578 /* True for resources whose filename extension is hidden (value type CFBoolean) */
cf7d2af9
A
579
580CF_EXPORT
8ca704e1
A
581const CFStringRef kCFURLCreationDateKey CF_AVAILABLE(10_6, 4_0);
582 /* The date the resource was created (value type CFDate) */
cf7d2af9
A
583
584CF_EXPORT
8ca704e1
A
585const CFStringRef kCFURLContentAccessDateKey CF_AVAILABLE(10_6, 4_0);
586 /* The date the resource was last accessed (Read-only, value type CFDate) */
cf7d2af9
A
587
588CF_EXPORT
8ca704e1
A
589const CFStringRef kCFURLContentModificationDateKey CF_AVAILABLE(10_6, 4_0);
590 /* The time the resource content was last modified (value type CFDate) */
cf7d2af9
A
591
592CF_EXPORT
8ca704e1
A
593const CFStringRef kCFURLAttributeModificationDateKey CF_AVAILABLE(10_6, 4_0);
594 /* The time the resource's attributes were last modified (value type CFDate) */
cf7d2af9
A
595
596CF_EXPORT
8ca704e1 597const CFStringRef kCFURLLinkCountKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
598 /* Number of hard links to the resource (Read-only, CFNumber) */
599
600CF_EXPORT
8ca704e1 601const CFStringRef kCFURLParentDirectoryURLKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
602 /* URL of the parent directory, if any (Read-only, value type CFURL) */
603
604CF_EXPORT
8ca704e1 605const CFStringRef kCFURLVolumeURLKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
606 /* URL of the volume on which the resource is stored (Read-only, value type CFURL) */
607
608CF_EXPORT
8ca704e1 609const CFStringRef kCFURLTypeIdentifierKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
610 /* Uniform type identifier for the resource (Read-only, value type CFString) */
611
612CF_EXPORT
8ca704e1 613const CFStringRef kCFURLLocalizedTypeDescriptionKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
614 /* User-visible type or "kind" descriptiopn (Read-only, value type CFString) */
615
616CF_EXPORT
8ca704e1 617const CFStringRef kCFURLLabelNumberKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
618 /* The label number assigned to the resource (value type CFNumber) */
619
620CF_EXPORT
8ca704e1 621const CFStringRef kCFURLLabelColorKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
622 /* The color of the assigned label (Read-only, value type CGColorRef, must link with Application Services) */
623
624CF_EXPORT
8ca704e1 625const CFStringRef kCFURLLocalizedLabelKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
626 /* The user-visible label text (Read-only, value type CFString) */
627
628CF_EXPORT
8ca704e1 629const CFStringRef kCFURLEffectiveIconKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
630 /* The icon normally displayed for the resource (Read-only, value type CGImageRef, must link with Application Services) */
631
632CF_EXPORT
8ca704e1 633const CFStringRef kCFURLCustomIconKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
634 /* The custom icon assigned to the resource, if any (value type CGImageRef, must link with Application Services) */
635
8ca704e1
A
636CF_EXPORT
637const 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
640CF_EXPORT
641const 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
644CF_EXPORT
645const 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
648CF_EXPORT
649const 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
652CF_EXPORT
653const 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
656CF_EXPORT
657const 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
660CF_EXPORT
661const 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
664CF_EXPORT
665const 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 */
669CF_EXPORT
670const CFStringRef kCFURLFileResourceTypeNamedPipe CF_AVAILABLE(10_7, 5_0);
671CF_EXPORT
672const CFStringRef kCFURLFileResourceTypeCharacterSpecial CF_AVAILABLE(10_7, 5_0);
673CF_EXPORT
674const CFStringRef kCFURLFileResourceTypeDirectory CF_AVAILABLE(10_7, 5_0);
675CF_EXPORT
676const CFStringRef kCFURLFileResourceTypeBlockSpecial CF_AVAILABLE(10_7, 5_0);
677CF_EXPORT
678const CFStringRef kCFURLFileResourceTypeRegular CF_AVAILABLE(10_7, 5_0);
679CF_EXPORT
680const CFStringRef kCFURLFileResourceTypeSymbolicLink CF_AVAILABLE(10_7, 5_0);
681CF_EXPORT
682const CFStringRef kCFURLFileResourceTypeSocket CF_AVAILABLE(10_7, 5_0);
683CF_EXPORT
684const CFStringRef kCFURLFileResourceTypeUnknown CF_AVAILABLE(10_7, 5_0);
cf7d2af9
A
685
686/* File Properties */
687
688CF_EXPORT
8ca704e1 689const CFStringRef kCFURLFileSizeKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
690 /* Total file size, in bytes (Read-only, value type CFNumber) */
691
692CF_EXPORT
8ca704e1 693const CFStringRef kCFURLFileAllocatedSizeKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
694 /* Total size of blocks allocated (Read-only, value type CFNumber) */
695
696CF_EXPORT
8ca704e1
A
697const 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
700CF_EXPORT
701const 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
704CF_EXPORT
705const 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
708CF_EXPORT
709const 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) */
cf7d2af9
A
711
712
713/* Volume Properties */
714
715/* For convenience, volume properties may be requested from any resource on a volume. */
716
717CF_EXPORT
8ca704e1 718const CFStringRef kCFURLVolumeLocalizedFormatDescriptionKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
719 /* The user-visible volume format (Read-only, value type CFString) */
720
721CF_EXPORT
8ca704e1 722const CFStringRef kCFURLVolumeTotalCapacityKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
723 /* Total volume capacity in bytes (Read-only, value type CFNumber) */
724
725CF_EXPORT
8ca704e1 726const CFStringRef kCFURLVolumeAvailableCapacityKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
727 /* Total free space, in bytes (Read-only, value type CFNumber) */
728
729CF_EXPORT
8ca704e1 730const CFStringRef kCFURLVolumeResourceCountKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
731 /* Total number of resources on the volume (Read-only, value type CFNumber) */
732
733CF_EXPORT
8ca704e1 734const CFStringRef kCFURLVolumeSupportsPersistentIDsKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
735 /* Read-only, value type CFBoolean */
736
737CF_EXPORT
8ca704e1 738const CFStringRef kCFURLVolumeSupportsSymbolicLinksKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
739 /* Read-only, value type CFBoolean */
740
741CF_EXPORT
8ca704e1 742const CFStringRef kCFURLVolumeSupportsHardLinksKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
743 /* Read-only, value type CFBoolean */
744
745CF_EXPORT
8ca704e1 746const CFStringRef kCFURLVolumeSupportsJournalingKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
747 /* Read-only, value type CFBoolean */
748
749CF_EXPORT
8ca704e1 750const CFStringRef kCFURLVolumeIsJournalingKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
751 /* Read-only, value type CFBoolean */
752
753CF_EXPORT
8ca704e1 754const CFStringRef kCFURLVolumeSupportsSparseFilesKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
755 /* Read-only, value type CFBoolean */
756
757CF_EXPORT
8ca704e1 758const CFStringRef kCFURLVolumeSupportsZeroRunsKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
759 /* Read-only, value type CFBoolean */
760
761CF_EXPORT
8ca704e1 762const CFStringRef kCFURLVolumeSupportsCaseSensitiveNamesKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
763 /* Read-only, value type CFBoolean */
764
765CF_EXPORT
8ca704e1 766const CFStringRef kCFURLVolumeSupportsCasePreservedNamesKey CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
767 /* Read-only, value type CFBoolean */
768
8ca704e1
A
769CF_EXPORT
770const 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
773CF_EXPORT
774const 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
777CF_EXPORT
778const CFStringRef kCFURLVolumeSupportsRenamingKey CF_AVAILABLE(10_7, 5_0);
779 /* true if the volume can be renamed. (Read-only, value type CFBoolean) */
780
781CF_EXPORT
782const 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
785CF_EXPORT
786const CFStringRef kCFURLVolumeSupportsExtendedSecurityKey CF_AVAILABLE(10_7, 5_0);
787 /* true if the volume implements extended security (ACLs). (Read-only, value type CFBoolean) */
788
789CF_EXPORT
790const 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
793CF_EXPORT
794const 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
797CF_EXPORT
798const 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
801CF_EXPORT
802const 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
805CF_EXPORT
806const 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
809CF_EXPORT
810const 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
813CF_EXPORT
814const 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
817CF_EXPORT
818const CFStringRef kCFURLVolumeIsReadOnlyKey CF_AVAILABLE(10_7, 5_0);
819 /* true if the volume is read-only. (Read-only, value type CFBoolean) */
820
821CF_EXPORT
822const 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
825CF_EXPORT
826const 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
829CF_EXPORT
830const 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
833CF_EXPORT
834const CFStringRef kCFURLVolumeNameKey CF_AVAILABLE(10_7, 5_0);
835 /* The name of the volume (settable if kCFURLVolumeSupportsRenamingKey is true, value type CFString) */
836
837CF_EXPORT
838const 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
843CF_EXPORT
844const 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
847CF_EXPORT
848const CFStringRef kCFURLUbiquitousItemHasUnresolvedConflictsKey CF_AVAILABLE(10_7, 5_0);
849 /* true if this item has conflicts outstanding. (Read-only, value type CFBoolean) */
850
851CF_EXPORT
852const 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
855CF_EXPORT
856const CFStringRef kCFURLUbiquitousItemIsDownloadingKey CF_AVAILABLE(10_7, 5_0);
857 /* true if data is being downloaded for this item. (Read-only, value type CFBoolean) */
858
859CF_EXPORT
860const 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
863CF_EXPORT
864const CFStringRef kCFURLUbiquitousItemIsUploadingKey CF_AVAILABLE(10_7, 5_0);
865 /* true if data is being uploaded for this item. (Read-only, value type CFBoolean) */
866
867CF_EXPORT
868const CFStringRef kCFURLUbiquitousItemPercentDownloadedKey CF_AVAILABLE(10_7, 5_0);
869 /* [0-100] percent of data downloaded. (Read-only, value type double CFNumber) */
870
871CF_EXPORT
872const CFStringRef kCFURLUbiquitousItemPercentUploadedKey CF_AVAILABLE(10_7, 5_0);
873 /* [0-100] percent of data downloaded. (Read-only, value type double CFNumber) */
874
cf7d2af9
A
875enum {
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};
880typedef CFOptionFlags CFURLBookmarkCreationOptions;
881
882enum {
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};
886typedef CFOptionFlags CFURLBookmarkResolutionOptions;
887
888typedef 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() */
8ca704e1
A
900CF_EXPORT
901CFDataRef CFURLCreateBookmarkData ( CFAllocatorRef allocator, CFURLRef url, CFURLBookmarkCreationOptions options, CFArrayRef resourcePropertiesToInclude, CFURLRef relativeToURL, CFErrorRef* error ) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
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 */
8ca704e1
A
919CF_EXPORT
920CFURLRef CFURLCreateByResolvingBookmarkData ( CFAllocatorRef allocator, CFDataRef bookmark, CFURLBookmarkResolutionOptions options, CFURLRef relativeToURL, CFArrayRef resourcePropertiesToInclude, Boolean* isStale, CFErrorRef* error ) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
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 ) */
8ca704e1
A
929CF_EXPORT
930CFDictionaryRef CFURLCreateResourcePropertiesForKeysFromBookmarkData ( CFAllocatorRef allocator, CFArrayRef resourcePropertiesToReturn, CFDataRef bookmark ) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
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 ) */
8ca704e1
A
939CF_EXPORT
940CFTypeRef CFURLCreateResourcePropertyForKeyFromBookmarkData( CFAllocatorRef allocator, CFStringRef resourcePropertyKey, CFDataRef bookmark ) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
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 */
8ca704e1
A
952CF_EXPORT
953CFDataRef CFURLCreateBookmarkDataFromFile(CFAllocatorRef allocator, CFURLRef fileURL, CFErrorRef *errorRef ) CF_AVAILABLE(10_6, 5_0);
cf7d2af9
A
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 */
8ca704e1
A
966CF_EXPORT
967Boolean CFURLWriteBookmarkDataToFile( CFDataRef bookmarkRef, CFURLRef fileURL, CFURLBookmarkFileCreationOptions options, CFErrorRef *errorRef ) CF_AVAILABLE(10_6, 5_0);
cf7d2af9
A
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 */
8ca704e1
A
977CF_EXPORT
978CFDataRef CFURLCreateBookmarkDataFromAliasRecord ( CFAllocatorRef allocatorRef, CFDataRef aliasRecordDataRef ) CF_AVAILABLE_MAC(10_6);
cf7d2af9 979
8ca704e1 980#endif /* TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE */
cf7d2af9 981
bd5b749c 982CF_EXTERN_C_END
9ce05555 983
bd5b749c 984#endif /* ! __COREFOUNDATION_CFURL__ */
9ce05555 985