/* * Copyright (c) 2012 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in * compliance with the License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this * file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. * Please see the License for the specific language governing rights and * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ /* CFURL.h Copyright (c) 1998-2011, Apple Inc. All rights reserved. */ #if !defined(__COREFOUNDATION_CFURL__) #define __COREFOUNDATION_CFURL__ 1 #include <CoreFoundation/CFBase.h> #include <CoreFoundation/CFData.h> #include <CoreFoundation/CFError.h> #include <CoreFoundation/CFString.h> #include <CoreFoundation/CFNumber.h> CF_EXTERN_C_BEGIN enum { kCFURLPOSIXPathStyle = 0, kCFURLHFSPathStyle, kCFURLWindowsPathStyle }; typedef CFIndex CFURLPathStyle; typedef const struct __CFURL * CFURLRef; /* CFURLs are composed of two fundamental pieces - their string, and a */ /* (possibly NULL) base URL. A relative URL is one in which the string */ /* by itself does not fully specify the URL (for instance "myDir/image.tiff"); */ /* an absolute URL is one in which the string does fully specify the URL */ /* ("file://localhost/myDir/image.tiff"). Absolute URLs always have NULL */ /* base URLs; however, it is possible for a URL to have a NULL base, and still */ /* not be absolute. Such a URL has only a relative string, and cannot be */ /* resolved. Two CFURLs are considered equal if and only if their strings */ /* are equal and their bases are equal. In other words, */ /* "file://localhost/myDir/image.tiff" is NOT equal to the URL with relative */ /* string "myDir/image.tiff" and base URL "file://localhost/". Clients that */ /* need these less strict form of equality should convert all URLs to their */ /* absolute form via CFURLCopyAbsoluteURL(), then compare the absolute forms. */ CF_EXPORT CFTypeID CFURLGetTypeID(void); /* encoding will be used both to interpret the bytes of URLBytes, and to */ /* interpret any percent-escapes within the bytes. */ CF_EXPORT CFURLRef CFURLCreateWithBytes(CFAllocatorRef allocator, const UInt8 *URLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL); /* Escapes any character that is not 7-bit ASCII with the byte-code */ /* for the given encoding. If escapeWhitespace is true, whitespace */ /* characters (' ', '\t', '\r', '\n') will be escaped also (desirable */ /* if embedding the URL into a larger text stream like HTML) */ CF_EXPORT CFDataRef CFURLCreateData(CFAllocatorRef allocator, CFURLRef url, CFStringEncoding encoding, Boolean escapeWhitespace); /* Any escape sequences in URLString will be interpreted via UTF-8. */ CF_EXPORT CFURLRef CFURLCreateWithString(CFAllocatorRef allocator, CFStringRef URLString, CFURLRef baseURL); /* Create an absolute URL directly, without requiring the extra step */ /* of calling CFURLCopyAbsoluteURL(). If useCompatibilityMode is */ /* true, the rules historically used on the web are used to resolve */ /* relativeString against baseURL - these rules are generally listed */ /* in the RFC as optional or alternate interpretations. Otherwise, */ /* the strict rules from the RFC are used. The major differences are */ /* that in compatibility mode, we are lenient of the scheme appearing */ /* in relative portion, leading "../" components are removed from the */ /* final URL's path, and if the relative portion contains only */ /* resource specifier pieces (query, parameters, and fragment), then */ /* the last path component of the base URL will not be deleted */ CF_EXPORT CFURLRef CFURLCreateAbsoluteURLWithBytes(CFAllocatorRef alloc, const UInt8 *relativeURLBytes, CFIndex length, CFStringEncoding encoding, CFURLRef baseURL, Boolean useCompatibilityMode); /* filePath should be the URL's path expressed as a path of the type */ /* fsType. If filePath is not absolute, the resulting URL will be */ /* considered relative to the current working directory (evaluated */ /* at creation time). isDirectory determines whether filePath is */ /* treated as a directory path when resolving against relative path */ /* components */ CF_EXPORT CFURLRef CFURLCreateWithFileSystemPath(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory); CF_EXPORT CFURLRef CFURLCreateFromFileSystemRepresentation(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory); /* The path style of the baseURL must match the path style of the relative */ /* url or the results are undefined. If the provided filePath looks like an */ /* absolute path ( starting with '/' if pathStyle is kCFURLPosixPathStyle, */ /* not starting with ':' for kCFURLHFSPathStyle, or starting with what looks */ /* like a drive letter and colon for kCFURLWindowsPathStyle ) then the baseURL */ /* is ignored. */ CF_EXPORT CFURLRef CFURLCreateWithFileSystemPathRelativeToBase(CFAllocatorRef allocator, CFStringRef filePath, CFURLPathStyle pathStyle, Boolean isDirectory, CFURLRef baseURL); CF_EXPORT CFURLRef CFURLCreateFromFileSystemRepresentationRelativeToBase(CFAllocatorRef allocator, const UInt8 *buffer, CFIndex bufLen, Boolean isDirectory, CFURLRef baseURL); /* Fills buffer with the file system's native representation of */ /* url's path. No more than maxBufLen bytes are written to buffer. */ /* The buffer should be at least the maximum path length for */ /* the file system in question to avoid failures for insufficiently */ /* large buffers. If resolveAgainstBase is true, the url's relative */ /* portion is resolved against its base before the path is computed. */ /* Returns success or failure. */ CF_EXPORT Boolean CFURLGetFileSystemRepresentation(CFURLRef url, Boolean resolveAgainstBase, UInt8 *buffer, CFIndex maxBufLen); /* Creates a new URL by resolving the relative portion of relativeURL against its base. */ CF_EXPORT CFURLRef CFURLCopyAbsoluteURL(CFURLRef relativeURL); /* Returns the URL's string. */ CF_EXPORT CFStringRef CFURLGetString(CFURLRef anURL); /* Returns the base URL if it exists */ CF_EXPORT CFURLRef CFURLGetBaseURL(CFURLRef anURL); /* All URLs can be broken into two pieces - the scheme (preceding the first colon) and the resource specifier (following the first colon). Most URLs are also "standard" URLs conforming to RFC 1808 (available from www.w3c.org). This category includes URLs of the file, http, https, and ftp schemes, to name a few. Standard URLs start the resource specifier with two slashes ("//"), and can be broken into four distinct pieces - the scheme, the net location, the path, and further resource specifiers (typically an optional parameter, query, and/or fragment). The net location appears immediately following the two slashes and goes up to the next slash; it's format is scheme-specific, but is usually composed of some or all of a username, password, host name, and port. The path is a series of path components separated by slashes; if the net location is present, the path always begins with a slash. Standard URLs can be relative to another URL, in which case at least the scheme and possibly other pieces as well come from the base URL (see RFC 1808 for precise details when resolving a relative URL against its base). The full URL is therefore <scheme> "://" <net location> <path, always starting with slash> <add'l resource specifiers> If a given CFURL can be decomposed (that is, conforms to RFC 1808), you can ask for each of the four basic pieces (scheme, net location, path, and resource specifer) separately, as well as for its base URL. The basic pieces are returned with any percent escape sequences still in place (although note that the scheme may not legally include any percent escapes); this is to allow the caller to distinguish between percent sequences that may have syntactic meaning if replaced by the character being escaped (for instance, a '/' in a path component). Since only the individual schemes know which characters are syntactically significant, CFURL cannot safely replace any percent escape sequences. However, you can use CFURLCreateStringByReplacingPercentEscapes() to create a new string with the percent escapes removed; see below. If a given CFURL can not be decomposed, you can ask for its scheme and its resource specifier; asking it for its net location or path will return NULL. To get more refined information about the components of a decomposable CFURL, you may ask for more specific pieces of the URL, expressed with the percent escapes removed. The available functions are CFURLCopyHostName(), CFURLGetPortNumber() (returns an Int32), CFURLCopyUserName(), CFURLCopyPassword(), CFURLCopyQuery(), CFURLCopyParameters(), and CFURLCopyFragment(). Because the parameters, query, and fragment of an URL may contain scheme-specific syntaxes, these methods take a second argument, giving a list of characters which should NOT be replaced if percent escaped. For instance, the ftp parameter syntax gives simple key-value pairs as "<key>=<value>;" Clearly if a key or value includes either '=' or ';', it must be escaped to avoid corrupting the meaning of the parameters, so the caller may request the parameter string as CFStringRef myParams = CFURLCopyParameters(ftpURL, CFSTR("=;%")); requesting that all percent escape sequences be replaced by the represented characters, except for escaped '=', '%' or ';' characters. Pass the empty string (CFSTR("")) to request that all percent escapes be replaced, or NULL to request that none be. */ /* Returns true if anURL conforms to RFC 1808 */ CF_EXPORT Boolean CFURLCanBeDecomposed(CFURLRef anURL); /* The next several methods leave any percent escape sequences intact */ CF_EXPORT CFStringRef CFURLCopyScheme(CFURLRef anURL); /* NULL if CFURLCanBeDecomposed(anURL) is false */ CF_EXPORT CFStringRef CFURLCopyNetLocation(CFURLRef anURL); /* NULL if CFURLCanBeDecomposed(anURL) is false; also does not resolve the URL */ /* against its base. See also CFURLCopyAbsoluteURL(). Note that, strictly */ /* speaking, any leading '/' is not considered part of the URL's path, although */ /* its presence or absence determines whether the path is absolute. */ /* CFURLCopyPath()'s return value includes any leading slash (giving the path */ /* the normal POSIX appearance); CFURLCopyStrictPath()'s return value omits any */ /* leading slash, and uses isAbsolute to report whether the URL's path is absolute. */ /* CFURLCopyFileSystemPath() returns the URL's path as a file system path for the */ /* given path style. All percent escape sequences are replaced. The URL is not */ /* resolved against its base before computing the path. */ CF_EXPORT CFStringRef CFURLCopyPath(CFURLRef anURL); CF_EXPORT CFStringRef CFURLCopyStrictPath(CFURLRef anURL, Boolean *isAbsolute); CF_EXPORT CFStringRef CFURLCopyFileSystemPath(CFURLRef anURL, CFURLPathStyle pathStyle); /* Returns whether anURL's path represents a directory */ /* (true returned) or a simple file (false returned) */ CF_EXPORT Boolean CFURLHasDirectoryPath(CFURLRef anURL); /* Any additional resource specifiers after the path. For URLs */ /* that cannot be decomposed, this is everything except the scheme itself. */ CF_EXPORT CFStringRef CFURLCopyResourceSpecifier(CFURLRef anURL); CF_EXPORT CFStringRef CFURLCopyHostName(CFURLRef anURL); CF_EXPORT SInt32 CFURLGetPortNumber(CFURLRef anURL); /* Returns -1 if no port number is specified */ CF_EXPORT CFStringRef CFURLCopyUserName(CFURLRef anURL); CF_EXPORT CFStringRef CFURLCopyPassword(CFURLRef anURL); /* These remove all percent escape sequences except those for */ /* characters in charactersToLeaveEscaped. If charactersToLeaveEscaped */ /* is empty (""), all percent escape sequences are replaced by their */ /* corresponding characters. If charactersToLeaveEscaped is NULL, */ /* then no escape sequences are removed at all */ CF_EXPORT CFStringRef CFURLCopyParameterString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped); CF_EXPORT CFStringRef CFURLCopyQueryString(CFURLRef anURL, CFStringRef charactersToLeaveEscaped); CF_EXPORT CFStringRef CFURLCopyFragment(CFURLRef anURL, CFStringRef charactersToLeaveEscaped); CF_EXPORT CFStringRef CFURLCopyLastPathComponent(CFURLRef url); CF_EXPORT CFStringRef CFURLCopyPathExtension(CFURLRef url); /* These functions all treat the base URL of the supplied url as */ /* invariant. In other words, the URL returned will always have */ /* the same base as the URL supplied as an argument. */ CF_EXPORT CFURLRef CFURLCreateCopyAppendingPathComponent(CFAllocatorRef allocator, CFURLRef url, CFStringRef pathComponent, Boolean isDirectory); CF_EXPORT CFURLRef CFURLCreateCopyDeletingLastPathComponent(CFAllocatorRef allocator, CFURLRef url); CF_EXPORT CFURLRef CFURLCreateCopyAppendingPathExtension(CFAllocatorRef allocator, CFURLRef url, CFStringRef extension); CF_EXPORT CFURLRef CFURLCreateCopyDeletingPathExtension(CFAllocatorRef allocator, CFURLRef url); /* Fills buffer with the bytes for url, returning the number of bytes */ /* filled. If buffer is of insufficient size, returns -1 and no bytes */ /* are placed in buffer. If buffer is NULL, the needed length is */ /* computed and returned. The returned bytes are the original bytes */ /* from which the URL was created; if the URL was created from a */ /* string, the bytes will be the bytes of the string encoded via UTF-8 */ CF_EXPORT CFIndex CFURLGetBytes(CFURLRef url, UInt8 *buffer, CFIndex bufferLength); enum { kCFURLComponentScheme = 1, kCFURLComponentNetLocation = 2, kCFURLComponentPath = 3, kCFURLComponentResourceSpecifier = 4, kCFURLComponentUser = 5, kCFURLComponentPassword = 6, kCFURLComponentUserInfo = 7, kCFURLComponentHost = 8, kCFURLComponentPort = 9, kCFURLComponentParameterString = 10, kCFURLComponentQuery = 11, kCFURLComponentFragment = 12 }; typedef CFIndex CFURLComponentType; /* Gets the range of the requested component in the bytes of url, as returned by CFURLGetBytes(). This range is only good for use in the bytes returned by CFURLGetBytes! If non-NULL, rangeIncludingSeparators gives the range of component including the sequences that separate component from the previous and next components. If there is no previous or next component, that end of rangeIncludingSeparators will match the range of the component itself. If url does not contain the given component type, (kCFNotFound, 0) is returned, and rangeIncludingSeparators is set to the location where the component would be inserted. Some examples - For the URL http://www.apple.com/hotnews/ Component returned range rangeIncludingSeparators scheme (0, 4) (0, 7) net location (7, 13) (4, 16) path (20, 9) (20, 9) resource specifier (kCFNotFound, 0) (29, 0) user (kCFNotFound, 0) (7, 0) password (kCFNotFound, 0) (7, 0) user info (kCFNotFound, 0) (7, 0) host (7, 13) (4, 16) port (kCFNotFound, 0) (20, 0) parameter (kCFNotFound, 0) (29, 0) query (kCFNotFound, 0) (29, 0) fragment (kCFNotFound, 0) (29, 0) For the URL ./relPath/file.html#fragment Component returned range rangeIncludingSeparators scheme (kCFNotFound, 0) (0, 0) net location (kCFNotFound, 0) (0, 0) path (0, 19) (0, 20) resource specifier (20, 8) (19, 9) user (kCFNotFound, 0) (0, 0) password (kCFNotFound, 0) (0, 0) user info (kCFNotFound, 0) (0, 0) host (kCFNotFound, 0) (0, 0) port (kCFNotFound, 0) (0, 0) parameter (kCFNotFound, 0) (19, 0) query (kCFNotFound, 0) (19, 0) fragment (20, 8) (19, 9) For the URL scheme://user:pass@host:1/path/path2/file.html;params?query#fragment Component returned range rangeIncludingSeparators scheme (0, 6) (0, 9) net location (9, 16) (6, 19) path (25, 21) (25, 22) resource specifier (47, 21) (46, 22) user (9, 4) (6, 8) password (14, 4) (13, 6) user info (9, 9) (6, 13) host (19, 4) (18, 6) port (24, 1) (23, 2) parameter (47, 6) (46, 8) query (54, 5) (53, 7) fragment (60, 8) (59, 9) */ CF_EXPORT CFRange CFURLGetByteRangeForComponent(CFURLRef url, CFURLComponentType component, CFRange *rangeIncludingSeparators); /* Returns a string with any percent escape sequences that do NOT */ /* correspond to characters in charactersToLeaveEscaped with their */ /* equivalent. Returns NULL on failure (if an invalid percent sequence */ /* is encountered), or the original string (retained) if no characters */ /* need to be replaced. Pass NULL to request that no percent escapes be */ /* replaced, or the empty string (CFSTR("")) to request that all percent */ /* escapes be replaced. Uses UTF8 to interpret percent escapes. */ CF_EXPORT CFStringRef CFURLCreateStringByReplacingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveEscaped); /* As above, but allows you to specify the encoding to use when interpreting percent escapes */ CF_EXPORT CFStringRef CFURLCreateStringByReplacingPercentEscapesUsingEncoding(CFAllocatorRef allocator, CFStringRef origString, CFStringRef charsToLeaveEscaped, CFStringEncoding encoding); /* Creates a copy or originalString, replacing certain characters with */ /* the equivalent percent escape sequence based on the encoding specified. */ /* If the originalString does not need to be modified (no percent escape */ /* sequences are missing), may retain and return originalString. */ /* If you are uncertain of the correct encoding, you should use UTF-8, */ /* which is the encoding designated by RFC 2396 as the correct encoding */ /* for use in URLs. The characters so escaped are all characters that */ /* are not legal URL characters (based on RFC 2396), plus any characters */ /* in legalURLCharactersToBeEscaped, less any characters in */ /* charactersToLeaveUnescaped. To simply correct any non-URL characters */ /* in an otherwise correct URL string, do: */ /* newString = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, origString, NULL, NULL, kCFStringEncodingUTF8); */ CF_EXPORT CFStringRef CFURLCreateStringByAddingPercentEscapes(CFAllocatorRef allocator, CFStringRef originalString, CFStringRef charactersToLeaveUnescaped, CFStringRef legalURLCharactersToBeEscaped, CFStringEncoding encoding); #if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION /* Returns a file reference URL, a path-idependent form of file URL. */ /* Converts a file path URL if necessary. For non-file URLs, returns NULL. */ /* Also returns NULL when the conversion fails because the target resource doesn't exist. */ /* Optional output error: The error is set to a valid CFErrorRef when the function */ /* result is NULL. A valid output error must be released by the caller. */ CF_EXPORT CFURLRef CFURLCreateFileReferenceURL(CFAllocatorRef allocator, CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); /* Returns a file path URL, converting a file reference URL if necessary. */ /* For non-file URLs, returns NULL. Also returns NULL when the conversion fails */ /* because the target resource doesn't exist. */ /* Optional output error: The error is set to a valid CFErrorRef when the function */ /* result is NULL. A valid output error must be released by the caller. */ CF_EXPORT CFURLRef CFURLCreateFilePathURL(CFAllocatorRef allocator, CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); #endif #if (TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE) || CF_BUILDING_CF || NSBUILDINGFOUNDATION /* The following APIs provide efficient access to resource properties. Properties are identified by keys, and values are represented as Core Foundation objects. The type of each value is fixed for each property, e.g. the modification date is a CFDateRef, the file size is a CFNumberRef. Values are fetched on-demand, synchronously, from the resource's backing store. They are cached and reused when fetched again through the same URL instance, until the client clears the value. The client has complete control over the cache lifetime. Some resource property values can be changed, given sufficient access permission to the resource. When a resource property value is set, the change is written to backing store synchronously. */ /* Assigns the requested resource property value to the typeRefValuePtr output */ /* argument. Returns true if the output value was set. Note that NULL is a valid output value. */ /* The value is fetched synchronously from the resource backing store only if a value is not */ /* already cached. The type of the output value type varies by property (see property key */ /* definitions). Returns false if an error occurs. Optional output error: the error is set to */ /* a valid CFErrorRef when the function returns false. A valid output error must be */ /* released by the caller. */ CF_EXPORT Boolean CFURLCopyResourcePropertyForKey(CFURLRef url, CFStringRef key, void *propertyValueTypeRefPtr, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); /* Returns any number of resource property values as a dictionary of keyed values. */ /* The requested values are specified as an array of keys to appear in */ /* the result dictionary. Values are fetched synchronously from the resource backing store unless */ /* already cached. The type of each value type varies (see key definitions, below). */ /* Returns an empty dictionary if no values are found. Returns NULL when an error occurs. */ /* Optional output error: the error is set to a valid CFErrorRef when the */ /* function returns NULL. A valid output error must be released by the caller. */ CF_EXPORT CFDictionaryRef CFURLCopyResourcePropertiesForKeys(CFURLRef url, CFArrayRef keys, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); /* Changes a resource property value. Synchronously writes the value to the resource backing */ /* store. The input value type must be a valid CFTypeRef, of the type required for the specified */ /* key (see key definitions). Returns true upon success, false when an error occurs. */ /* Optional output error: the error is set to a valid CFErrorRef when the function */ /* returns false. A valid output error must be released by the caller. */ /* Note that some values are read-only. Attempting to set a read-only property */ /* results in an error. */ CF_EXPORT Boolean CFURLSetResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); /* Changes any number of resource property values, specified as a dictionary of keyed values. */ /* Synchronously writes values to the resource backing store. The input dictionary's value types must conform */ /* to the type required for its key (see key definitions). Returns true when all values are set successfully, */ /* and false if an error occurs. Optional output error: the error is set to a valid CFErrorRef when the function returns */ /* false. A valid output error must be released by the caller. When an error occurs after some properties have been */ /* successfully changed, the userInfo dictionary in the error contains an array of keys that */ /* were not set with the dictionary key kCFURLKeysOfUnsetValuesKey. */ /* Note that some values are read-only. Attempting to set a read-only value results in an error. */ CF_EXPORT Boolean CFURLSetResourcePropertiesForKeys(CFURLRef url, CFDictionaryRef keyedPropertyValues, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); CF_EXPORT const CFStringRef kCFURLKeysOfUnsetValuesKey CF_AVAILABLE(10_7, 5_0); /* If CFURLSetResourcePropertiesForKeys returns an error, this is key in the error's userInfo dictionary to the array of keys of unset values. */ /* Discards a cached property value for a specific key */ CF_EXPORT void CFURLClearResourcePropertyCacheForKey(CFURLRef url, CFStringRef key) CF_AVAILABLE(10_6, 4_0); /* Discards all cached property values */ CF_EXPORT void CFURLClearResourcePropertyCache(CFURLRef url) CF_AVAILABLE(10_6, 4_0); /* Sets a temporary property value. Temporary properties exist only in memory and are never */ /* written to resource backing store. Once set, a temporary property value can be fetched */ /* with CFURLCopyResourcePropertyForKey and CFURLCopyResourcePropertiesForKeys. Temporary property */ /* values are for client use. Values must be valid Core Foundation types, and will be retained. */ /* To remove a temporary property value, use CFURLClearResourcePropertyCacheForKey. */ CF_EXPORT void CFURLSetTemporaryResourcePropertyForKey(CFURLRef url, CFStringRef key, CFTypeRef propertyValue) CF_AVAILABLE(10_6, 4_0); /* Synchronously checks if the resource's backing store is reachable and the resource exists, */ /* returning true if so. The optional output error can be used to determine the type of reachability */ /* failure (e.g., file not found, network error, etc.). The error is set to a valid CFErrorRef if */ /* and only if the function returns false. A valid output error must be released by */ /* the caller. Checking for resource existence and reachability is appropriate when making decisions */ /* that do not require other immediate operations on the resource. An example would be */ /* periodic maintenance of UI state that depends on the existence of a particular document. */ /* When performing an operation such as opening a file, it is more efficient to */ /* simply try the operation and handle failures than to check first for reachability. */ CF_EXPORT Boolean CFURLResourceIsReachable(CFURLRef url, CFErrorRef *error) CF_AVAILABLE(10_6, 4_0); /* Properties of File System Resources */ CF_EXPORT const CFStringRef kCFURLNameKey CF_AVAILABLE(10_6, 4_0); /* The resource name provided by the file system (value type CFString) */ CF_EXPORT const CFStringRef kCFURLLocalizedNameKey CF_AVAILABLE(10_6, 4_0); /* Localized or extension-hidden name as displayed to users (Read-only, value type CFString) */ CF_EXPORT const CFStringRef kCFURLIsRegularFileKey CF_AVAILABLE(10_6, 4_0); /* True for regular files (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLIsDirectoryKey CF_AVAILABLE(10_6, 4_0); /* True for directories (Read-only, CFBoolean) */ CF_EXPORT const CFStringRef kCFURLIsSymbolicLinkKey CF_AVAILABLE(10_6, 4_0); /* True for symlinks (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLIsVolumeKey CF_AVAILABLE(10_6, 4_0); /* True for the root directory of a volume (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLIsPackageKey CF_AVAILABLE(10_6, 4_0); /* True for packaged directories (value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLIsSystemImmutableKey CF_AVAILABLE(10_6, 4_0); /* True for system-immutable resources (value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLIsUserImmutableKey CF_AVAILABLE(10_6, 4_0); /* True for user-immutable resources (value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLIsHiddenKey CF_AVAILABLE(10_6, 4_0); /* True for resources normally hidden from users (value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLHasHiddenExtensionKey CF_AVAILABLE(10_6, 4_0); /* True for resources whose filename extension is hidden (value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLCreationDateKey CF_AVAILABLE(10_6, 4_0); /* The date the resource was created (value type CFDate) */ CF_EXPORT const CFStringRef kCFURLContentAccessDateKey CF_AVAILABLE(10_6, 4_0); /* The date the resource was last accessed (Read-only, value type CFDate) */ CF_EXPORT const CFStringRef kCFURLContentModificationDateKey CF_AVAILABLE(10_6, 4_0); /* The time the resource content was last modified (value type CFDate) */ CF_EXPORT const CFStringRef kCFURLAttributeModificationDateKey CF_AVAILABLE(10_6, 4_0); /* The time the resource's attributes were last modified (value type CFDate) */ CF_EXPORT const CFStringRef kCFURLLinkCountKey CF_AVAILABLE(10_6, 4_0); /* Number of hard links to the resource (Read-only, CFNumber) */ CF_EXPORT const CFStringRef kCFURLParentDirectoryURLKey CF_AVAILABLE(10_6, 4_0); /* URL of the parent directory, if any (Read-only, value type CFURL) */ CF_EXPORT const CFStringRef kCFURLVolumeURLKey CF_AVAILABLE(10_6, 4_0); /* URL of the volume on which the resource is stored (Read-only, value type CFURL) */ CF_EXPORT const CFStringRef kCFURLTypeIdentifierKey CF_AVAILABLE(10_6, 4_0); /* Uniform type identifier for the resource (Read-only, value type CFString) */ CF_EXPORT const CFStringRef kCFURLLocalizedTypeDescriptionKey CF_AVAILABLE(10_6, 4_0); /* User-visible type or "kind" descriptiopn (Read-only, value type CFString) */ CF_EXPORT const CFStringRef kCFURLLabelNumberKey CF_AVAILABLE(10_6, 4_0); /* The label number assigned to the resource (value type CFNumber) */ CF_EXPORT const CFStringRef kCFURLLabelColorKey CF_AVAILABLE(10_6, 4_0); /* The color of the assigned label (Read-only, value type CGColorRef, must link with Application Services) */ CF_EXPORT const CFStringRef kCFURLLocalizedLabelKey CF_AVAILABLE(10_6, 4_0); /* The user-visible label text (Read-only, value type CFString) */ CF_EXPORT const CFStringRef kCFURLEffectiveIconKey CF_AVAILABLE(10_6, 4_0); /* The icon normally displayed for the resource (Read-only, value type CGImageRef, must link with Application Services) */ CF_EXPORT const CFStringRef kCFURLCustomIconKey CF_AVAILABLE(10_6, 4_0); /* The custom icon assigned to the resource, if any (value type CGImageRef, must link with Application Services) */ CF_EXPORT const CFStringRef kCFURLFileResourceIdentifierKey CF_AVAILABLE(10_7, 5_0); /* 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) */ CF_EXPORT const CFStringRef kCFURLVolumeIdentifierKey CF_AVAILABLE(10_7, 5_0); /* 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) */ CF_EXPORT const CFStringRef kCFURLPreferredIOBlockSizeKey CF_AVAILABLE(10_7, 5_0); /* The optimal block size when reading or writing this file's data, or NULL if not available. (Read-only, value type CFNumber) */ CF_EXPORT const CFStringRef kCFURLIsReadableKey CF_AVAILABLE(10_7, 5_0); /* true if this process (as determined by EUID) can read the resource. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLIsWritableKey CF_AVAILABLE(10_7, 5_0); /* true if this process (as determined by EUID) can write to the resource. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLIsExecutableKey CF_AVAILABLE(10_7, 5_0); /* true if this process (as determined by EUID) can execute a file resource or search a directory resource. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLFileSecurityKey CF_AVAILABLE(10_7, 5_0); /* The file system object's security information encapsulated in a CFFileSecurity object. (Value type CFFileSecurity) */ CF_EXPORT const CFStringRef kCFURLFileResourceTypeKey CF_AVAILABLE(10_7, 5_0); /* Returns the file system object type. (Read-only, value type CFString) */ /* The file system object type values returned for the kCFURLFileResourceTypeKey */ CF_EXPORT const CFStringRef kCFURLFileResourceTypeNamedPipe CF_AVAILABLE(10_7, 5_0); CF_EXPORT const CFStringRef kCFURLFileResourceTypeCharacterSpecial CF_AVAILABLE(10_7, 5_0); CF_EXPORT const CFStringRef kCFURLFileResourceTypeDirectory CF_AVAILABLE(10_7, 5_0); CF_EXPORT const CFStringRef kCFURLFileResourceTypeBlockSpecial CF_AVAILABLE(10_7, 5_0); CF_EXPORT const CFStringRef kCFURLFileResourceTypeRegular CF_AVAILABLE(10_7, 5_0); CF_EXPORT const CFStringRef kCFURLFileResourceTypeSymbolicLink CF_AVAILABLE(10_7, 5_0); CF_EXPORT const CFStringRef kCFURLFileResourceTypeSocket CF_AVAILABLE(10_7, 5_0); CF_EXPORT const CFStringRef kCFURLFileResourceTypeUnknown CF_AVAILABLE(10_7, 5_0); /* File Properties */ CF_EXPORT const CFStringRef kCFURLFileSizeKey CF_AVAILABLE(10_6, 4_0); /* Total file size, in bytes (Read-only, value type CFNumber) */ CF_EXPORT const CFStringRef kCFURLFileAllocatedSizeKey CF_AVAILABLE(10_6, 4_0); /* Total size of blocks allocated (Read-only, value type CFNumber) */ CF_EXPORT const CFStringRef kCFURLTotalFileSizeKey CF_AVAILABLE(10_7, 5_0); /* 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) */ CF_EXPORT const CFStringRef kCFURLTotalFileAllocatedSizeKey CF_AVAILABLE(10_7, 5_0); /* 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) */ CF_EXPORT const CFStringRef kCFURLIsAliasFileKey CF_AVAILABLE(10_6, 4_0); /* true if the url is a Finder alias file, false otherwise ( Read-only, value type CFBooleanRef) */ CF_EXPORT const CFStringRef kCFURLIsMountTriggerKey CF_AVAILABLE(10_7, 4_0); /* 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) */ /* Volume Properties */ /* For convenience, volume properties may be requested from any resource on a volume. */ CF_EXPORT const CFStringRef kCFURLVolumeLocalizedFormatDescriptionKey CF_AVAILABLE(10_6, 4_0); /* The user-visible volume format (Read-only, value type CFString) */ CF_EXPORT const CFStringRef kCFURLVolumeTotalCapacityKey CF_AVAILABLE(10_6, 4_0); /* Total volume capacity in bytes (Read-only, value type CFNumber) */ CF_EXPORT const CFStringRef kCFURLVolumeAvailableCapacityKey CF_AVAILABLE(10_6, 4_0); /* Total free space, in bytes (Read-only, value type CFNumber) */ CF_EXPORT const CFStringRef kCFURLVolumeResourceCountKey CF_AVAILABLE(10_6, 4_0); /* Total number of resources on the volume (Read-only, value type CFNumber) */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsPersistentIDsKey CF_AVAILABLE(10_6, 4_0); /* Read-only, value type CFBoolean */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsSymbolicLinksKey CF_AVAILABLE(10_6, 4_0); /* Read-only, value type CFBoolean */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsHardLinksKey CF_AVAILABLE(10_6, 4_0); /* Read-only, value type CFBoolean */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsJournalingKey CF_AVAILABLE(10_6, 4_0); /* Read-only, value type CFBoolean */ CF_EXPORT const CFStringRef kCFURLVolumeIsJournalingKey CF_AVAILABLE(10_6, 4_0); /* Read-only, value type CFBoolean */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsSparseFilesKey CF_AVAILABLE(10_6, 4_0); /* Read-only, value type CFBoolean */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsZeroRunsKey CF_AVAILABLE(10_6, 4_0); /* Read-only, value type CFBoolean */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsCaseSensitiveNamesKey CF_AVAILABLE(10_6, 4_0); /* Read-only, value type CFBoolean */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsCasePreservedNamesKey CF_AVAILABLE(10_6, 4_0); /* Read-only, value type CFBoolean */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsRootDirectoryDatesKey CF_AVAILABLE(10_7, 5_0); /* true if the volume supports reliable storage of times for the root directory. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsVolumeSizesKey CF_AVAILABLE(10_7, 5_0); /* true if the volume supports returning volume size values (kCFURLVolumeTotalCapacityKey and kCFURLVolumeAvailableCapacityKey). (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsRenamingKey CF_AVAILABLE(10_7, 5_0); /* true if the volume can be renamed. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsAdvisoryFileLockingKey CF_AVAILABLE(10_7, 5_0); /* 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) */ CF_EXPORT const CFStringRef kCFURLVolumeSupportsExtendedSecurityKey CF_AVAILABLE(10_7, 5_0); /* true if the volume implements extended security (ACLs). (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLVolumeIsBrowsableKey CF_AVAILABLE(10_7, 5_0); /* 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) */ CF_EXPORT const CFStringRef kCFURLVolumeMaximumFileSizeKey CF_AVAILABLE(10_7, 5_0); /* The largest file size (in bytes) supported by this file system, or NULL if this cannot be determined. (Read-only, value type CFNumber) */ CF_EXPORT const CFStringRef kCFURLVolumeIsEjectableKey CF_AVAILABLE(10_7, 5_0); /* true if the volume's media is ejectable from the drive mechanism under software control. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLVolumeIsRemovableKey CF_AVAILABLE(10_7, 5_0); /* true if the volume's media is removable from the drive mechanism. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLVolumeIsInternalKey CF_AVAILABLE(10_7, 5_0); /* 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) */ CF_EXPORT const CFStringRef kCFURLVolumeIsAutomountedKey CF_AVAILABLE(10_7, 5_0); /* true if the volume is automounted. Note: do not mistake this with the functionality provided by kCFURLVolumeSupportsBrowsingKey. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLVolumeIsLocalKey CF_AVAILABLE(10_7, 5_0); /* true if the volume is stored on a local device. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLVolumeIsReadOnlyKey CF_AVAILABLE(10_7, 5_0); /* true if the volume is read-only. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLVolumeCreationDateKey CF_AVAILABLE(10_7, 5_0); /* The volume's creation date, or NULL if this cannot be determined. (Read-only, value type CFDate) */ CF_EXPORT const CFStringRef kCFURLVolumeURLForRemountingKey CF_AVAILABLE(10_7, 5_0); /* The CFURL needed to remount a network volume, or NULL if not available. (Read-only, value type CFURL) */ CF_EXPORT const CFStringRef kCFURLVolumeUUIDStringKey CF_AVAILABLE(10_7, 5_0); /* 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) */ CF_EXPORT const CFStringRef kCFURLVolumeNameKey CF_AVAILABLE(10_7, 5_0); /* The name of the volume (settable if kCFURLVolumeSupportsRenamingKey is true, value type CFString) */ CF_EXPORT const CFStringRef kCFURLVolumeLocalizedNameKey CF_AVAILABLE(10_7, 5_0); /* The user-presentable name of the volume (Read-only, value type CFString) */ /* UbiquitousItem Properties */ CF_EXPORT const CFStringRef kCFURLIsUbiquitousItemKey CF_AVAILABLE(10_7, 5_0); /* true if this item is synced to the cloud, false if it is only a local file. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLUbiquitousItemHasUnresolvedConflictsKey CF_AVAILABLE(10_7, 5_0); /* true if this item has conflicts outstanding. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLUbiquitousItemIsDownloadedKey CF_AVAILABLE(10_7, 5_0); /* true if there is local data present for this item. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLUbiquitousItemIsDownloadingKey CF_AVAILABLE(10_7, 5_0); /* true if data is being downloaded for this item. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLUbiquitousItemIsUploadedKey CF_AVAILABLE(10_7, 5_0); /* true if there is data present in the cloud for this item. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLUbiquitousItemIsUploadingKey CF_AVAILABLE(10_7, 5_0); /* true if data is being uploaded for this item. (Read-only, value type CFBoolean) */ CF_EXPORT const CFStringRef kCFURLUbiquitousItemPercentDownloadedKey CF_AVAILABLE(10_7, 5_0); /* [0-100] percent of data downloaded. (Read-only, value type double CFNumber) */ CF_EXPORT const CFStringRef kCFURLUbiquitousItemPercentUploadedKey CF_AVAILABLE(10_7, 5_0); /* [0-100] percent of data downloaded. (Read-only, value type double CFNumber) */ enum { kCFURLBookmarkCreationPreferFileIDResolutionMask = ( 1UL << 8 ), // At resolution time, this alias will prefer resolving by the embedded fileID to the path kCFURLBookmarkCreationMinimalBookmarkMask = ( 1UL << 9 ), // Creates a bookmark with "less" information, which may be smaller but still be able to resolve in certain ways kCFURLBookmarkCreationSuitableForBookmarkFile = ( 1UL << 10 ), // includes in the created bookmark those properties which are needed for a bookmark/alias file }; #if MAC_OS_X_VERSION_10_7 <= MAC_OS_X_VERSION_MAX_ALLOWED enum { kCFURLBookmarkCreationWithSecurityScope = ( 1UL << 11 ), // Mac OS X 10.7.3 and later, include information in the bookmark data which allows the same sandboxed process to access the resource after being relaunched kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess = ( 1UL << 12 ), // Mac OS X 10.7.3 and later, if used with kCFURLBookmarkCreationWithSecurityScope, at resolution time only read access to the resource will be granted }; #endif typedef CFOptionFlags CFURLBookmarkCreationOptions; enum { kCFBookmarkResolutionWithoutUIMask = ( 1UL << 8 ), // don't perform any UI during bookmark resolution kCFBookmarkResolutionWithoutMountingMask = ( 1UL << 9 ), // don't mount a volume during bookmark resolution }; #if MAC_OS_X_VERSION_10_7 <= MAC_OS_X_VERSION_MAX_ALLOWED enum { kCFURLBookmarkResolutionWithSecurityScope = ( 1UL << 10 ), // Mac OS X 10.7.3 and later, extract the security scope included at creation time to provide the ability to access the resource. }; #endif typedef CFOptionFlags CFURLBookmarkResolutionOptions; typedef CFOptionFlags CFURLBookmarkFileCreationOptions; /* @function CFURLCreateBookmarkData @discussion Create a CFDataRef containing an externalizable representation from a CFURLRef, modified with the given options, including ( at the minimum ) any properties in the propertiesToInclude array which are retrievable from the given url. @param allocator the CFAllocator to use to create this object @param url the CFURLRef to create a bookmark data from. @param options a set of options which control creation of the bookmark data @param resourcePropertiesToInclude If non-NULL, an CFArrayRef of additional properties copied from the url to include in the created bookmark data. @param relativeToURL If non-NULL, the created bookmark will be relative to the given url. If kCFURLBookmarkCreationWithSecurityScope is given as an option and relativeToURL is non-NULL, then a collection-scoped bookmark is created which enables future access to url provided the caller has access to relativeURL. @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 @result A CFDataRef containing an data, which can be later be passed to CFURLCreateByResolvingBookmarkData() or to CFURLCopyPropertiesForKeysFromBookmarkData() / CFURLCopyPropertyForKeyFromBookmarkData() */ CF_EXPORT CFDataRef CFURLCreateBookmarkData ( CFAllocatorRef allocator, CFURLRef url, CFURLBookmarkCreationOptions options, CFArrayRef resourcePropertiesToInclude, CFURLRef relativeToURL, CFErrorRef* error ) CF_AVAILABLE(10_6, 4_0); /* @function CFURLCreateByResolvingBookmarkData @discussion Given a CFDataRef created with CFURLCreateBookmarkRepresentation(), return a CFURLRef of the item it was a bookmark to, and attempt to pre-cache those properties in propertiesToInclude in the resulting url. If in the process of resolving the bookmark into the CFURLRef 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, 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 item cannot be found, return NULL. A bookmark created with security scope may fail to resolve if the caller does not have the same code signing identity as the caller which created the bookmark. After resolving a security scoped bookmark, the caller must call CFURLStartAccessingSecurityScopedResource() in order to gain access to the resource. If an error ( other than "original item can not be found" ) occurs during the process, return NULL and fill in error ) @param allocator the CFAllocator to use to create this object @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData @param options options which affect the resolution @param relativeToURL If non-NULL, and if the bookmark was created relative to another url, then resolve it relative to this url. If kCFURLBookmarkCreationWithSecurityScope was provided at creation, and kCFURLBookmarkResolutionWithSecurityScope is set, then relativeURL should point to the same item which was passed as relavitiveURL at creation time. @param resourcePropertiesToInclude If non-NULL, a CFArray containing those properties which the caller would like to already be cached on the given url @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 corresponding properties on the returned file. Clients, upon seeing a stale representation, may want to replace whatever stored bookmark data they have saved and create a new one. @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 @result A CFURLRef of a file which is the closest match to the file the bookmark data */ CF_EXPORT CFURLRef CFURLCreateByResolvingBookmarkData ( CFAllocatorRef allocator, CFDataRef bookmark, CFURLBookmarkResolutionOptions options, CFURLRef relativeToURL, CFArrayRef resourcePropertiesToInclude, Boolean* isStale, CFErrorRef* error ) CF_AVAILABLE(10_6, 4_0); /* @function CFURLCreatePropertiesForKeysFromBookmarkData @discussion Given a bookmark, return a dictionary of properties ( all properties if propertiesToReturn == NULL ). This returns only the properties stored within the bookmark and will not attempt to resolve the bookmark or do i/o. @param allocator the CFAllocator to use to create this object @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData @param propertiesToReturn a CFArrayRef of the properties of the bookmark data which the client would like returned. @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 ) */ CF_EXPORT CFDictionaryRef CFURLCreateResourcePropertiesForKeysFromBookmarkData ( CFAllocatorRef allocator, CFArrayRef resourcePropertiesToReturn, CFDataRef bookmark ) CF_AVAILABLE(10_6, 4_0); /* @function CFURLCreatePropertyForKeyFromBookmarkData @discussion Given a bookmark, return the value for a given property from the bookmark data This returns only the properties stored within the bookmark and will not attempt to resolve the bookmark or do i/o. @param allocator the CFAllocator to use to create this object @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData @param propertyKey the property key to return. @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 ) */ CF_EXPORT CFTypeRef CFURLCreateResourcePropertyForKeyFromBookmarkData( CFAllocatorRef allocator, CFStringRef resourcePropertyKey, CFDataRef bookmark ) CF_AVAILABLE(10_6, 4_0); /*! @function CFURLCreateBookmarkDataFromFile @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 created before SnowLeopard which contains Alias Manager information and no bookmark data, then a CFDataRef will be synthesized which contains 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 if it is corrupt, NULL will be returned and error will be filled in if errorRef is non-NULL. @param allocator the CFAllocator to use to create this object @param fileURL a CFURLRef to to the alias file to create the bookmark data from @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 @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. */ CF_EXPORT CFDataRef CFURLCreateBookmarkDataFromFile(CFAllocatorRef allocator, CFURLRef fileURL, CFErrorRef *errorRef ) CF_AVAILABLE(10_6, 5_0); /*! @function CFURLWriteBookmarkDataToFile @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 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 .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 systems running something before SnowLeopard to resolve this file using Alias Manager routines and get back the same file as the bookmark routines. The bookmark data must have been created with the kCFURLBookmarkCreationSuitableForBookmarkFile option and an error will be returned if not. @param allocator the CFAllocator to use to create this object @param bookmark a CFDataRef containing a bookmark data, created with CFURLCreateBookmarkData @param options options flags @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 */ CF_EXPORT Boolean CFURLWriteBookmarkDataToFile( CFDataRef bookmarkRef, CFURLRef fileURL, CFURLBookmarkFileCreationOptions options, CFErrorRef *errorRef ) CF_AVAILABLE(10_6, 5_0); /*! @function CFURLCreateBookmarkDataFromAliasRecord @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. 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 CFURLCreateResourcePropertiesForKeysFromBookmarkData() / CFURLCreateResourcePropertyForKeyFromBookmarkData(). @param allocator the CFAllocator to use to create this object @param aliasRecordDataRef the contents of an AliasRecord to create bookmark data for @result A CFDataRef containing an data, which can be later be passed to CFURLCreateByResolvingBookmarkData() or to CFURLCopyPropertiesForKeysFromBookmarkData() / CFURLCopyPropertyForKeyFromBookmarkData() */ CF_EXPORT CFDataRef CFURLCreateBookmarkDataFromAliasRecord ( CFAllocatorRef allocatorRef, CFDataRef aliasRecordDataRef ) CF_AVAILABLE_MAC(10_6); /*! @function CFURLStartAccessingSecurityScopedResource @discussion Given a CFURLRef created by resolving a bookmark data created with security scope, make the resource referenced by the url accessible to the process. When access to this resource is no longer needed the client should call CFURLStopAccessingSecurityScopedResource(). Each call to CFURLStartAccessingSecurityScopedResource() must be balanced with a call to CFURLStopAccessingSecurityScopedResource(). @param url the CFURLRef for the resource returned by CFURLCreateByResolvingBookmarkData() using kCFURLBookmarkResolutionWithSecurityScope. @result returns TRUE if access was granted and FALSE if the url does not reference a security scoped resource, or if some error occurred which didn't allow access to be granted */ Boolean CFURLStartAccessingSecurityScopedResource(CFURLRef url) CF_AVAILABLE(10_7, NA); // Available in MacOS X 10.7.3 and later /*! @function CFURLStopAccessingSecurityScopedResource @discussion Revokes the access granted to the url by a prior successful call to CFURLStartAccessingSecurityScopedResource(). @param url the CFURLRef for the resource to stop accessing. */ void CFURLStopAccessingSecurityScopedResource(CFURLRef url) CF_AVAILABLE(10_7, NA); #endif /* TARGET_OS_MAC || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE */ CF_EXTERN_C_END #endif /* ! __COREFOUNDATION_CFURL__ */