]> git.saurik.com Git - apple/cf.git/blame - URL.subproj/CFURLAccess.h
CF-368.28.tar.gz
[apple/cf.git] / URL.subproj / CFURLAccess.h
CommitLineData
9ce05555 1/*
d8925383 2 * Copyright (c) 2005 Apple Computer, 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 */
23/* CFURLAccess.h
d8925383 24 Copyright (c) 1998-2005, Apple, Inc. All rights reserved.
9ce05555
A
25*/
26
27#if !defined(__COREFOUNDATION_CFURLACCESS__)
28#define __COREFOUNDATION_CFURLACCESS__ 1
29
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>
36
37#if defined(__cplusplus)
38extern "C" {
39#endif
40
41/* Attempts to read the data and properties for the given URL. If
42only interested in one of the resourceData and properties, pass NULL
43for the other. If properties is non-NULL and desiredProperties is
44NULL, then all properties are fetched. Returns success or failure;
45note that as much work as possible is done even if false is returned.
46So for instance if one property is not available, the others are
47fetched anyway. errorCode is set to 0 on success, and some other
48value on failure. If non-NULL, it is the caller 's responsibility
49to release resourceData and properties.
50
51 Apple reserves for its use all negative error code values; these
52values represent errors common to any scheme. Scheme-specific error
53codes should be positive, non-zero, and should be used only if one of
54the predefined Apple error codes does not apply. Error codes should
55be publicized and documented with the scheme-specific properties.
d8925383
A
56
57NOTE: When asking for the resource data, this call will allocate the entire
58resource in memory. This can be very expensive, depending on the size of the
59resource (file). Please use CFStream or other techniques if you are downloading
60large files.
61
9ce05555
A
62*/
63CF_EXPORT
64Boolean CFURLCreateDataAndPropertiesFromResource(CFAllocatorRef alloc, CFURLRef url, CFDataRef *resourceData, CFDictionaryRef *properties, CFArrayRef desiredProperties, SInt32 *errorCode);
65
66/* Attempts to write the given data and properties to the given URL.
67If dataToWrite is NULL, only properties are written out (use
68CFURLDestroyResource() to delete a resource). Properties not present
69in propertiesToWrite are left unchanged, hence if propertiesToWrite
70is NULL or empty, the URL's properties are not changed at all.
71Returns success or failure; errorCode is set as for
72CFURLCreateDataAndPropertiesFromResource(), above.
73*/
74CF_EXPORT
75Boolean CFURLWriteDataAndPropertiesToResource(CFURLRef url, CFDataRef dataToWrite, CFDictionaryRef propertiesToWrite, SInt32 *errorCode);
76
77/* Destroys the resource indicated by url. */
78/* Returns success or failure; errorCode set as above. */
79CF_EXPORT
80Boolean CFURLDestroyResource(CFURLRef url, SInt32 *errorCode);
81
82/* Convenience method which calls through to CFURLCreateDataAndPropertiesFromResource(). */
83/* Returns NULL on error and sets errorCode accordingly. */
84CF_EXPORT
85CFTypeRef CFURLCreatePropertyFromResource(CFAllocatorRef alloc, CFURLRef url, CFStringRef property, SInt32 *errorCode);
86
87/* Common error codes; this list is expected to grow */
88typedef enum {
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
98} CFURLError;
99
100/* Property keys */
101
102CF_EXPORT
103const CFStringRef kCFURLFileExists;
104CF_EXPORT
105const CFStringRef kCFURLFileDirectoryContents;
106CF_EXPORT
107const CFStringRef kCFURLFileLength;
108CF_EXPORT
109const CFStringRef kCFURLFileLastModificationTime;
110CF_EXPORT
111const CFStringRef kCFURLFilePOSIXMode;
112CF_EXPORT
113const CFStringRef kCFURLFileOwnerID;
114CF_EXPORT
115const CFStringRef kCFURLHTTPStatusCode;
116CF_EXPORT
117const CFStringRef kCFURLHTTPStatusLine;
118
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 */
125
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 */
129
130#if defined(__cplusplus)
131}
132#endif
133
134#endif /* !__COREFOUNDATION_CFURLACCESS__ */
135