CFFTPStream Reference
| Derived from | |
| Framework | CoreServices |
| Companion guide | |
| Declared in | CFFTPStream.h |
Overview
This document describes the CFStream functions for working with FTP connections. It is part of the CFFTP API.
Functions
CFFTPCreateParsedResourceListing
Parses an FTP listing to a dictionary.
CFIndex CFFTPCreateParsedResourceListing ( CFAllocatorRef alloc, const UInt8 *buffer, CFIndex bufferLength, CFDictionaryRef *parsed );
Parameters
- alloc
The allocator to use to allocate memory for the dictionary. Pass
NULLorkCFAllocatorDefaultto use the current default allocator.- buffer
A pointer to a buffer holding zero or more lines of resource listing.
- bufferLength
The length in bytes of the buffer pointed to by
buffer.- parsed
Upon return, contains a dictionary containing the parsed resource information. If parsing fails, a
NULLpointer is returned.
Return Value
The number of bytes parsed, 0 if no bytes were available for parsing, or -1 if parsing failed.
Discussion
This function examines the contents of buffer as an FTP directory listing and parses into a CFDictionary the information for a single file or folder. The CFDictionary is returned in the parsed parameter, and the number of bytes used from buffer is returned.
Availability
- Available in iOS 2.0 and later.
Declared In
CFFTPStream.hCFReadStreamCreateWithFTPURL
CFReadStreamRef CFReadStreamCreateWithFTPURL ( CFAllocatorRef alloc, CFURLRef ftpURL );
Parameters
- alloc
The allocator to use to allocate memory for the new object. Pass
NULLorkCFAllocatorDefaultto use the current default allocator.- ftpURL
A pointer to a CFURL structure for the URL to be downloaded that can be created by calling any of the
CFURLCreatefunctions, such asCFURLCreateWithString.
Return Value
A new read stream, or NULL if the call failed. Ownership follows the Create Rule.
Discussion
This function creates an FTP read stream for downloading data from an FTP URL. If the ftpURL parameter is created with the user name and password as part of the URL (such as ftp://username:password@ftp.example.com) then the user name and password will automatically be set in the CFReadStream. Otherwise, call CFReadStreamSetProperty to set the steam’s properties, such as kCFStreamPropertyFTPUserName and kCFStreamPropertyFTPPassword to associate a user name and password with the stream that are used to log in when the stream is opened. See “Constants” for a description of all FTP stream properties.
To initiate a connection with the FTP server, call CFReadStreamOpen. To read the FTP stream, call CFReadStreamRead. If the URL refers to a directory, the stream provides the listing results sent by the server. If the URL refers to a file, the stream provides the data in that file.
To close a connection with the FTP server, call CFReadStreamClose.
Availability
- Available in iOS 2.0 and later.
Declared In
CFFTPStream.hCFWriteStreamCreateWithFTPURL
CFWriteStreamRef CFWriteStreamCreateWithFTPURL ( CFAllocatorRef alloc, CFURLRef ftpURL );
Parameters
- alloc
The allocator to use to allocate memory for the new object. Pass
NULLorkCFAllocatorDefaultto use the current default allocator.- ftpURL
A pointer to a CFURL structure for the URL to be uploaded created by calling any of the
CFURLCreatefunctions, such asCFURLCreateWithString.
Return Value
A new write stream, or NULL if the call failed. Ownership follows the Create Rule.
Discussion
This function creates an FTP write stream for uploading data to an FTP URL. If the ftpURL parameter is created with the user name and password as part of the URL (such as ftp://username:password@ftp.example.com) then the user name and password will automatically be set in the CFWriteStream. Call CFWriteStreamSetProperty to set the steam’s properties, such as kCFStreamPropertyFTPUserName and kCFStreamPropertyFTPPassword to associate a user name and password with the stream that are used to log in when the stream is opened. See “Constants” for a description of all FTP stream properties.
After creating the write stream, you can call CFWriteStreamGetStatus at any time to check the status of the stream.
To initiate a connection with the FTP server, call CFWriteStreamOpen. If the URL specifies a directory, the open is immediately followed by the event kCFStreamEventEndEncountered (and the stream passes to the state kCFStreamStatusAtEnd). Once the stream reaches this state, the directory has been created. Intermediary directories are not created.
To write to the FTP stream, call CFWriteStreamWrite.
To close a connection with the FTP server, call CFWriteStreamClose.
Availability
- Available in iOS 2.0 and later.
Declared In
CFFTPStream.hConstants
CFStream FTP Property Constants
Constants for setting and copying CFStream FTP properties.
const CFStringRef kCFStreamPropertyFTPUserName; const CFStringRef kCFStreamPropertyFTPPassword; const CFStringRef kCFStreamPropertyFTPUsePassiveMode; const CFStringRef kCFStreamPropertyFTPResourceSize; const CFStringRef kCFStreamPropertyFTPFetchResourceInfo; const CFStringRef kCFStreamPropertyFTPFileTransferOffset; const CFStringRef kCFStreamPropertyFTPAttemptPersistentConnection; const CFStringRef kCFStreamPropertyFTPProxy; const CFStringRef kCFStreamPropertyFTPProxyHost; extern const CFStringRef kCFStreamPropertyFTPProxyPort; extern const CFStringRef kCFStreamPropertyFTPProxyUser; extern const CFStringRef kCFStreamPropertyFTPProxyPassword;
Constants
kCFStreamPropertyFTPUserNameFTP User Name stream property key for set and copy operations. A value of type CFString for storing the login user name. Don’t set this property when anonymous FTP is desired.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPPasswordFTP Password stream property key for set and copy operations. A value of type CFString for storing the login password. Don’t set this property when anonymous FTP is desired.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPUsePassiveModeFTP Passive Mode stream property key for set and copy operations. Set this property to
kCFBooleanTrueto enable passive mode; set this property tokCFBooleanFalseto disable passive mode.Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPResourceSizeFTP Resource Size read stream property key copy operations. This property stores a CFNumber of type
kCFNumberLongLongTyperepresenting the size of a resource in bytes.Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPFetchResourceInfoFTP Fetch Resource Information stream property key for set and copy operations. Set this property to
kCFBooleanTrueto require that resource information, such as size, must be provided before download starts; set this property tokCFBooleanFalseto allow downloads to start without resource information. For this version, size is the only resource information.Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPFileTransferOffsetFTP File Transfer Offset stream property key for set and copy operations. The value of this property is a CFNumber of type
kCFNumberLongLongTyperepresenting the file offset at which to start the transfer.Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPAttemptPersistentConnectionFTP Attempt Persistent Connection stream property key for set and copy operations. Set this property to
kCFBooleanTrueto enable the reuse of existing server connections; set this property tokCFBooleanFalseto not reuse existing server connections. By default, this property is set tokCFBooleanTrue.Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPProxyFTP Proxy stream property key for set and copy operations. The property is a value of type CFDictionary that holds proxy dictionary key-value pairs. The dictionary returned by SystemConfiguration can also be set as the value of this property.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPProxyHostFTP Proxy Host stream property key or an FTP Proxy dictionary key for set and copy operations. The value of this property is a CFString containing the host name of a proxy server. This property can be set and copied individually or via a CFDictionary. This property is the same as the
kSCPropNetProxiesFTPProxyproperty defined inSCSchemaDefinitions.h.Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPProxyPortFTP Proxy Port stream property key or an FTP Proxy dictionary key for set and copy operations. The value of this property is a CFNumber of type
kCFNumberIntTypecontaining the port number of a proxy server. This property can be set and copied individually or via a CFDictionary. This property is the same as thekSCPropNetProxiesFTPPortproperty defined inSCSchemaDefinitions.h.Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPProxyUserFTP Proxy Host stream property key or FTP Proxy dictionary key for set and copy operations. The value of this property is a CFString containing the username to be used when connecting to the proxy server.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFStreamPropertyFTPProxyPasswordFTP Proxy Port stream property key or FTP Proxy dictionary key for set and copy operations. The value of this property is a CFString containing the password to be used when connecting to the proxy server.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.
Discussion
The CFStream property constants are used to specify the property to set when calling CFReadStreamSetProperty or CFWriteStreamSetProperty and to copy when calling CFReadStreamCopyProperty or CFWriteStreamCopyProperty. They can also be passed to a CFDictionary creator or to an item accessor or mutator.
Availability
- Available in OS X version 10.3 and later.
Declared In
CFNetwork/CFFTPStream.hCFStream FTP Resource Constants
FTP resource constants.
const CFStringRef kCFFTPResourceMode; const CFStringRef kCFFTPResourceName; const CFStringRef kCFFTPResourceOwner; const CFStringRef kCFFTPResourceGroup; const CFStringRef kCFFTPResourceLink; const CFStringRef kCFFTPResourceSize; const CFStringRef kCFFTPResourceType; const CFStringRef kCFFTPResourceModDate;
Constants
kCFFTPResourceModeCFDictionary key for getting the CFNumber containing the access permissions, defined in
sys/types.h, of the FTP resource.Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFFTPResourceNameCFDictionary key for getting the CFString containing the name of the FTP resource.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFFTPResourceOwnerCFDictionary key for getting the CFString containing the name of the owner of the FTP resource.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFFTPResourceGroupCFDictionary key for getting the CFString containing the name of a group that shares the FTP resource.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFFTPResourceLinkCFDictionary key for getting the CFString containing the symbolic link information. If the item is a symbolic link, the CFString contains the path to the item that the link references.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFFTPResourceSizeCFDictionary key for getting the CFNumber containing the size in bytes of the FTP resource.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFFTPResourceTypeCFDictionary key for getting the CFNumber containing the type of the FTP resource as defined in
sys/dirent.h.Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.kCFFTPResourceModDateCFDictionary key for getting the CFDate containing the last date and time the FTP resource was modified.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.
Discussion
The values of FTP resource keys are extracted from a line of the directory list by the CFFTPCreateParsedResourceListing function.
Availability
- Available in OS X version 10.3 and later.
Declared In
CFNetwork/CFFTPStream.hError Domains
Error domains specific to CFFTPStream calls.
extern const SInt32 kCFStreamErrorDomainFTP;
Constants
kCFStreamErrorDomainFTPError domain that returns the last result code returned by the FTP server.
Available in iOS 2.0 and later.
Declared in
CFFTPStream.h.
Discussion
To determine the source of an error, examine the userInfo dictionary included in the CFError object returned by a function call or call CFErrorGetDomain and pass in the CFError object and the domain whose value you want to read.
© 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-07-11)