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