2 * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 Copyright (c) 1998-2005, Apple, Inc. All rights reserved.
27 #if !defined(__COREFOUNDATION_CFURLACCESS__)
28 #define __COREFOUNDATION_CFURLACCESS__ 1
30 #include <CoreFoundation/CFBase.h>
31 #include <CoreFoundation/CFArray.h>
32 #include <CoreFoundation/CFData.h>
33 #include <CoreFoundation/CFDictionary.h>
34 #include <CoreFoundation/CFString.h>
35 #include <CoreFoundation/CFURL.h>
37 #if defined(__cplusplus)
41 /* Attempts to read the data and properties for the given URL. If
42 only interested in one of the resourceData and properties, pass NULL
43 for the other. If properties is non-NULL and desiredProperties is
44 NULL, then all properties are fetched. Returns success or failure;
45 note that as much work as possible is done even if false is returned.
46 So for instance if one property is not available, the others are
47 fetched anyway. errorCode is set to 0 on success, and some other
48 value on failure. If non-NULL, it is the caller 's responsibility
49 to release resourceData and properties.
51 Apple reserves for its use all negative error code values; these
52 values represent errors common to any scheme. Scheme-specific error
53 codes should be positive, non-zero, and should be used only if one of
54 the predefined Apple error codes does not apply. Error codes should
55 be publicized and documented with the scheme-specific properties.
57 NOTE: When asking for the resource data, this call will allocate the entire
58 resource in memory. This can be very expensive, depending on the size of the
59 resource (file). Please use CFStream or other techniques if you are downloading
64 Boolean
CFURLCreateDataAndPropertiesFromResource(CFAllocatorRef alloc
, CFURLRef url
, CFDataRef
*resourceData
, CFDictionaryRef
*properties
, CFArrayRef desiredProperties
, SInt32
*errorCode
);
66 /* Attempts to write the given data and properties to the given URL.
67 If dataToWrite is NULL, only properties are written out (use
68 CFURLDestroyResource() to delete a resource). Properties not present
69 in propertiesToWrite are left unchanged, hence if propertiesToWrite
70 is NULL or empty, the URL's properties are not changed at all.
71 Returns success or failure; errorCode is set as for
72 CFURLCreateDataAndPropertiesFromResource(), above.
75 Boolean
CFURLWriteDataAndPropertiesToResource(CFURLRef url
, CFDataRef dataToWrite
, CFDictionaryRef propertiesToWrite
, SInt32
*errorCode
);
77 /* Destroys the resource indicated by url. */
78 /* Returns success or failure; errorCode set as above. */
80 Boolean
CFURLDestroyResource(CFURLRef url
, SInt32
*errorCode
);
82 /* Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource(). */
83 /* Returns NULL on error and sets errorCode accordingly. */
85 CFTypeRef
CFURLCreatePropertyFromResource(CFAllocatorRef alloc
, CFURLRef url
, CFStringRef property
, SInt32
*errorCode
);
87 /* Common error codes; this list is expected to grow */
89 kCFURLUnknownError
= -10,
90 kCFURLUnknownSchemeError
= -11,
91 kCFURLResourceNotFoundError
= -12,
92 kCFURLResourceAccessViolationError
= -13,
93 kCFURLRemoteHostUnavailableError
= -14,
94 kCFURLImproperArgumentsError
= -15,
95 kCFURLUnknownPropertyKeyError
= -16,
96 kCFURLPropertyKeyUnavailableError
= -17,
97 kCFURLTimeoutError
= -18
103 const CFStringRef kCFURLFileExists
;
105 const CFStringRef kCFURLFileDirectoryContents
;
107 const CFStringRef kCFURLFileLength
;
109 const CFStringRef kCFURLFileLastModificationTime
;
111 const CFStringRef kCFURLFilePOSIXMode
;
113 const CFStringRef kCFURLFileOwnerID
;
115 const CFStringRef kCFURLHTTPStatusCode
;
117 const CFStringRef kCFURLHTTPStatusLine
;
119 /* The value of kCFURLFileExists is a CFBoolean */
120 /* The value of kCFURLFileDirectoryContents is a CFArray containing CFURLs. An empty array means the directory exists, but is empty */
121 /* The value of kCFURLFileLength is a CFNumber giving the file's length in bytes */
122 /* The value of kCFURLFileLastModificationTime is a CFDate */
123 /* The value of kCFURLFilePOSIXMode is a CFNumber as given in stat.h */
124 /* The value of kCFURLFileOwnerID is a CFNumber representing the owner's uid */
126 /* 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 */
127 /* The value of kCFURLHTTPStatusCode is a CFNumber */
128 /* The value of kCFURLHTTPStatusLine is a CFString */
130 #if defined(__cplusplus)
134 #endif /* !__COREFOUNDATION_CFURLACCESS__ */