]>
Commit | Line | Data |
---|---|---|
9ce05555 | 1 | /* |
e588f561 | 2 | * Copyright (c) 2010 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 | /* CFURLAccess.h |
cf7d2af9 | 25 | Copyright (c) 1998-2009, Apple Inc. All rights reserved. |
9ce05555 A |
26 | */ |
27 | ||
28 | #if !defined(__COREFOUNDATION_CFURLACCESS__) | |
29 | #define __COREFOUNDATION_CFURLACCESS__ 1 | |
30 | ||
31 | #include <CoreFoundation/CFBase.h> | |
32 | #include <CoreFoundation/CFArray.h> | |
33 | #include <CoreFoundation/CFData.h> | |
34 | #include <CoreFoundation/CFDictionary.h> | |
cf7d2af9 | 35 | #include <CoreFoundation/CFError.h> |
9ce05555 A |
36 | #include <CoreFoundation/CFString.h> |
37 | #include <CoreFoundation/CFURL.h> | |
38 | ||
bd5b749c | 39 | CF_EXTERN_C_BEGIN |
9ce05555 | 40 | |
cf7d2af9 A |
41 | |
42 | ||
9ce05555 A |
43 | /* Attempts to read the data and properties for the given URL. If |
44 | only interested in one of the resourceData and properties, pass NULL | |
45 | for the other. If properties is non-NULL and desiredProperties is | |
46 | NULL, then all properties are fetched. Returns success or failure; | |
47 | note that as much work as possible is done even if false is returned. | |
48 | So for instance if one property is not available, the others are | |
49 | fetched anyway. errorCode is set to 0 on success, and some other | |
50 | value on failure. If non-NULL, it is the caller 's responsibility | |
51 | to release resourceData and properties. | |
52 | ||
53 | Apple reserves for its use all negative error code values; these | |
54 | values represent errors common to any scheme. Scheme-specific error | |
55 | codes should be positive, non-zero, and should be used only if one of | |
56 | the predefined Apple error codes does not apply. Error codes should | |
57 | be publicized and documented with the scheme-specific properties. | |
d8925383 A |
58 | |
59 | NOTE: When asking for the resource data, this call will allocate the entire | |
60 | resource in memory. This can be very expensive, depending on the size of the | |
61 | resource (file). Please use CFStream or other techniques if you are downloading | |
62 | large files. | |
63 | ||
9ce05555 A |
64 | */ |
65 | CF_EXPORT | |
cf7d2af9 | 66 | Boolean CFURLCreateDataAndPropertiesFromResource(CFAllocatorRef alloc, CFURLRef url, CFDataRef *resourceData, CFDictionaryRef *properties, CFArrayRef desiredProperties, SInt32 *errorCode) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 A |
67 | |
68 | /* Attempts to write the given data and properties to the given URL. | |
69 | If dataToWrite is NULL, only properties are written out (use | |
70 | CFURLDestroyResource() to delete a resource). Properties not present | |
71 | in propertiesToWrite are left unchanged, hence if propertiesToWrite | |
72 | is NULL or empty, the URL's properties are not changed at all. | |
73 | Returns success or failure; errorCode is set as for | |
74 | CFURLCreateDataAndPropertiesFromResource(), above. | |
75 | */ | |
76 | CF_EXPORT | |
cf7d2af9 | 77 | Boolean CFURLWriteDataAndPropertiesToResource(CFURLRef url, CFDataRef dataToWrite, CFDictionaryRef propertiesToWrite, SInt32 *errorCode) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 A |
78 | |
79 | /* Destroys the resource indicated by url. */ | |
80 | /* Returns success or failure; errorCode set as above. */ | |
81 | CF_EXPORT | |
cf7d2af9 | 82 | Boolean CFURLDestroyResource(CFURLRef url, SInt32 *errorCode) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 A |
83 | |
84 | /* Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource(). */ | |
85 | /* Returns NULL on error and sets errorCode accordingly. */ | |
86 | CF_EXPORT | |
cf7d2af9 A |
87 | CFTypeRef CFURLCreatePropertyFromResource(CFAllocatorRef alloc, CFURLRef url, CFStringRef property, SInt32 *errorCode) AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
88 | ||
9ce05555 | 89 | |
cf7d2af9 | 90 | /* Common error codes (returned only by the older APIs that predate CFError) */ |
bd5b749c | 91 | enum { |
9ce05555 A |
92 | kCFURLUnknownError = -10, |
93 | kCFURLUnknownSchemeError = -11, | |
94 | kCFURLResourceNotFoundError = -12, | |
95 | kCFURLResourceAccessViolationError = -13, | |
96 | kCFURLRemoteHostUnavailableError = -14, | |
97 | kCFURLImproperArgumentsError = -15, | |
98 | kCFURLUnknownPropertyKeyError = -16, | |
99 | kCFURLPropertyKeyUnavailableError = -17, | |
100 | kCFURLTimeoutError = -18 | |
bd5b749c A |
101 | }; |
102 | typedef CFIndex CFURLError; | |
9ce05555 | 103 | |
cf7d2af9 | 104 | /* Older property keys */ |
9ce05555 A |
105 | |
106 | CF_EXPORT | |
cf7d2af9 | 107 | const CFStringRef kCFURLFileExists AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 | 108 | CF_EXPORT |
cf7d2af9 | 109 | const CFStringRef kCFURLFileDirectoryContents AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 | 110 | CF_EXPORT |
cf7d2af9 | 111 | const CFStringRef kCFURLFileLength AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 | 112 | CF_EXPORT |
cf7d2af9 | 113 | const CFStringRef kCFURLFileLastModificationTime AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 | 114 | CF_EXPORT |
cf7d2af9 | 115 | const CFStringRef kCFURLFilePOSIXMode AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 | 116 | CF_EXPORT |
cf7d2af9 | 117 | const CFStringRef kCFURLFileOwnerID AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 | 118 | CF_EXPORT |
cf7d2af9 | 119 | const CFStringRef kCFURLHTTPStatusCode AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 | 120 | CF_EXPORT |
cf7d2af9 | 121 | const CFStringRef kCFURLHTTPStatusLine AVAILABLE_MAC_OS_X_VERSION_10_0_AND_LATER; |
9ce05555 A |
122 | |
123 | /* The value of kCFURLFileExists is a CFBoolean */ | |
124 | /* The value of kCFURLFileDirectoryContents is a CFArray containing CFURLs. An empty array means the directory exists, but is empty */ | |
125 | /* The value of kCFURLFileLength is a CFNumber giving the file's length in bytes */ | |
126 | /* The value of kCFURLFileLastModificationTime is a CFDate */ | |
127 | /* The value of kCFURLFilePOSIXMode is a CFNumber as given in stat.h */ | |
128 | /* The value of kCFURLFileOwnerID is a CFNumber representing the owner's uid */ | |
129 | ||
130 | /* Properties for the http: scheme. Except for the common error codes, above, errorCode will be set to the HTTP response status code upon failure. Any HTTP header name can also be used as a property */ | |
131 | /* The value of kCFURLHTTPStatusCode is a CFNumber */ | |
132 | /* The value of kCFURLHTTPStatusLine is a CFString */ | |
133 | ||
bd5b749c | 134 | CF_EXTERN_C_END |
9ce05555 | 135 | |
bd5b749c | 136 | #endif /* ! __COREFOUNDATION_CFURLACCESS__ */ |
9ce05555 | 137 |