]> git.saurik.com Git - apple/cf.git/blob - URL.subproj/CFURLAccess.h
CF-299.3.tar.gz
[apple/cf.git] / URL.subproj / CFURLAccess.h
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /* CFURLAccess.h
26 Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
27 */
28
29 #if !defined(__COREFOUNDATION_CFURLACCESS__)
30 #define __COREFOUNDATION_CFURLACCESS__ 1
31
32 #include <CoreFoundation/CFBase.h>
33 #include <CoreFoundation/CFArray.h>
34 #include <CoreFoundation/CFData.h>
35 #include <CoreFoundation/CFDictionary.h>
36 #include <CoreFoundation/CFString.h>
37 #include <CoreFoundation/CFURL.h>
38
39 #if defined(__cplusplus)
40 extern "C" {
41 #endif
42
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.
58 */
59 CF_EXPORT
60 Boolean CFURLCreateDataAndPropertiesFromResource(CFAllocatorRef alloc, CFURLRef url, CFDataRef *resourceData, CFDictionaryRef *properties, CFArrayRef desiredProperties, SInt32 *errorCode);
61
62 /* Attempts to write the given data and properties to the given URL.
63 If dataToWrite is NULL, only properties are written out (use
64 CFURLDestroyResource() to delete a resource). Properties not present
65 in propertiesToWrite are left unchanged, hence if propertiesToWrite
66 is NULL or empty, the URL's properties are not changed at all.
67 Returns success or failure; errorCode is set as for
68 CFURLCreateDataAndPropertiesFromResource(), above.
69 */
70 CF_EXPORT
71 Boolean CFURLWriteDataAndPropertiesToResource(CFURLRef url, CFDataRef dataToWrite, CFDictionaryRef propertiesToWrite, SInt32 *errorCode);
72
73 /* Destroys the resource indicated by url. */
74 /* Returns success or failure; errorCode set as above. */
75 CF_EXPORT
76 Boolean CFURLDestroyResource(CFURLRef url, SInt32 *errorCode);
77
78 /* Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource(). */
79 /* Returns NULL on error and sets errorCode accordingly. */
80 CF_EXPORT
81 CFTypeRef CFURLCreatePropertyFromResource(CFAllocatorRef alloc, CFURLRef url, CFStringRef property, SInt32 *errorCode);
82
83 /* Common error codes; this list is expected to grow */
84 typedef enum {
85 kCFURLUnknownError = -10,
86 kCFURLUnknownSchemeError = -11,
87 kCFURLResourceNotFoundError = -12,
88 kCFURLResourceAccessViolationError = -13,
89 kCFURLRemoteHostUnavailableError = -14,
90 kCFURLImproperArgumentsError = -15,
91 kCFURLUnknownPropertyKeyError = -16,
92 kCFURLPropertyKeyUnavailableError = -17,
93 kCFURLTimeoutError = -18
94 } CFURLError;
95
96 /* Property keys */
97
98 CF_EXPORT
99 const CFStringRef kCFURLFileExists;
100 CF_EXPORT
101 const CFStringRef kCFURLFileDirectoryContents;
102 CF_EXPORT
103 const CFStringRef kCFURLFileLength;
104 CF_EXPORT
105 const CFStringRef kCFURLFileLastModificationTime;
106 CF_EXPORT
107 const CFStringRef kCFURLFilePOSIXMode;
108 CF_EXPORT
109 const CFStringRef kCFURLFileOwnerID;
110 CF_EXPORT
111 const CFStringRef kCFURLHTTPStatusCode;
112 CF_EXPORT
113 const CFStringRef kCFURLHTTPStatusLine;
114
115 /* The value of kCFURLFileExists is a CFBoolean */
116 /* The value of kCFURLFileDirectoryContents is a CFArray containing CFURLs. An empty array means the directory exists, but is empty */
117 /* The value of kCFURLFileLength is a CFNumber giving the file's length in bytes */
118 /* The value of kCFURLFileLastModificationTime is a CFDate */
119 /* The value of kCFURLFilePOSIXMode is a CFNumber as given in stat.h */
120 /* The value of kCFURLFileOwnerID is a CFNumber representing the owner's uid */
121
122 /* 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 */
123 /* The value of kCFURLHTTPStatusCode is a CFNumber */
124 /* The value of kCFURLHTTPStatusLine is a CFString */
125
126 #if defined(__cplusplus)
127 }
128 #endif
129
130 #endif /* !__COREFOUNDATION_CFURLACCESS__ */
131