2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
26 Copyright (c) 1998-2003, Apple, Inc. All rights reserved.
29 #if !defined(__COREFOUNDATION_CFURLACCESS__)
30 #define __COREFOUNDATION_CFURLACCESS__ 1
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>
39 #if defined(__cplusplus)
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.
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.
60 Boolean
CFURLCreateDataAndPropertiesFromResource(CFAllocatorRef alloc
, CFURLRef url
, CFDataRef
*resourceData
, CFDictionaryRef
*properties
, CFArrayRef desiredProperties
, SInt32
*errorCode
);
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.
71 Boolean
CFURLWriteDataAndPropertiesToResource(CFURLRef url
, CFDataRef dataToWrite
, CFDictionaryRef propertiesToWrite
, SInt32
*errorCode
);
73 /* Destroys the resource indicated by url. */
74 /* Returns success or failure; errorCode set as above. */
76 Boolean
CFURLDestroyResource(CFURLRef url
, SInt32
*errorCode
);
78 /* Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource(). */
79 /* Returns NULL on error and sets errorCode accordingly. */
81 CFTypeRef
CFURLCreatePropertyFromResource(CFAllocatorRef alloc
, CFURLRef url
, CFStringRef property
, SInt32
*errorCode
);
83 /* Common error codes; this list is expected to grow */
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
99 const CFStringRef kCFURLFileExists
;
101 const CFStringRef kCFURLFileDirectoryContents
;
103 const CFStringRef kCFURLFileLength
;
105 const CFStringRef kCFURLFileLastModificationTime
;
107 const CFStringRef kCFURLFilePOSIXMode
;
109 const CFStringRef kCFURLFileOwnerID
;
111 const CFStringRef kCFURLHTTPStatusCode
;
113 const CFStringRef kCFURLHTTPStatusLine
;
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 */
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 */
126 #if defined(__cplusplus)
130 #endif /* !__COREFOUNDATION_CFURLACCESS__ */