iOS Developer Library

Developer

CoreServices Framework Reference CFFTPStream Reference

Options
Deployment Target:

On This Page
Language:

CFFTPStream Reference

Inheritance


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import CFNetwork

Objective-C

@import CFNetwork;

This document describes the CFStream functions for working with FTP connections. It is part of the CFFTP API.

Functions

  • Creates an FTP read stream.

    Declaration

    Swift

    func CFReadStreamCreateWithFTPURL(_ alloc: CFAllocator!, _ ftpURL: CFURL!) -> Unmanaged<CFReadStream>!

    Objective-C

    CFReadStreamRef CFReadStreamCreateWithFTPURL ( CFAllocatorRef alloc, CFURLRef ftpURL );

    Parameters

    alloc

    The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to 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 CFURLCreate functions, such as CFURLCreateWithString.

    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.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Creates an FTP write stream.

    Declaration

    Swift

    func CFWriteStreamCreateWithFTPURL(_ alloc: CFAllocator!, _ ftpURL: CFURL!) -> Unmanaged<CFWriteStream>!

    Objective-C

    CFWriteStreamRef CFWriteStreamCreateWithFTPURL ( CFAllocatorRef alloc, CFURLRef ftpURL );

    Parameters

    alloc

    The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.

    ftpURL

    A pointer to a CFURL structure for the URL to be uploaded created by calling any of the CFURLCreate functions, such as CFURLCreateWithString.

    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.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

  • Parses an FTP listing to a dictionary.

    Declaration

    Swift

    func CFFTPCreateParsedResourceListing(_ alloc: CFAllocator!, _ buffer: UnsafePointer<UInt8>, _ bufferLength: CFIndex, _ parsed: UnsafeMutablePointer<Unmanaged<CFDictionary>?>) -> CFIndex

    Objective-C

    CFIndex CFFTPCreateParsedResourceListing ( CFAllocatorRef alloc, const UInt8 *buffer, CFIndex bufferLength, CFDictionaryRef *parsed );

    Parameters

    alloc

    The allocator to use to allocate memory for the dictionary. Pass NULL or kCFAllocatorDefault to 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 NULL pointer 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.

    Import Statement

    Objective-C

    @import CFNetwork;

    Swift

    import CFNetwork

    Availability

    Available in iOS 2.0 and later.

Constants

  • Constants for setting and copying CFStream FTP properties.

    Declaration

    Swift

    let kCFStreamPropertyFTPUserName: CFString! let kCFStreamPropertyFTPPassword: CFString! let kCFStreamPropertyFTPUsePassiveMode: CFString! let kCFStreamPropertyFTPResourceSize: CFString! let kCFStreamPropertyFTPFetchResourceInfo: CFString! let kCFStreamPropertyFTPFileTransferOffset: CFString! let kCFStreamPropertyFTPAttemptPersistentConnection: CFString! let kCFStreamPropertyFTPProxy: CFString! let kCFStreamPropertyFTPProxyHost: CFString! let kCFStreamPropertyFTPProxyPort: CFString! let kCFStreamPropertyFTPProxyUser: CFString! let kCFStreamPropertyFTPProxyPassword: CFString!

    Objective-C

    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

    • kCFStreamPropertyFTPUserName

      kCFStreamPropertyFTPUserName

      FTP 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.

    • kCFStreamPropertyFTPPassword

      kCFStreamPropertyFTPPassword

      FTP 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.

    • kCFStreamPropertyFTPUsePassiveMode

      kCFStreamPropertyFTPUsePassiveMode

      FTP Passive Mode stream property key for set and copy operations. Set this property to kCFBooleanTrue to enable passive mode; set this property to kCFBooleanFalse to disable passive mode.

      Available in iOS 2.0 and later.

    • kCFStreamPropertyFTPResourceSize

      kCFStreamPropertyFTPResourceSize

      FTP Resource Size read stream property key copy operations. This property stores a CFNumber of type kCFNumberLongLongType representing the size of a resource in bytes.

      Available in iOS 2.0 and later.

    • kCFStreamPropertyFTPFetchResourceInfo

      kCFStreamPropertyFTPFetchResourceInfo

      FTP Fetch Resource Information stream property key for set and copy operations. Set this property to kCFBooleanTrue to require that resource information, such as size, must be provided before download starts; set this property to kCFBooleanFalse to allow downloads to start without resource information. For this version, size is the only resource information.

      Available in iOS 2.0 and later.

    • kCFStreamPropertyFTPFileTransferOffset

      kCFStreamPropertyFTPFileTransferOffset

      FTP File Transfer Offset stream property key for set and copy operations. The value of this property is a CFNumber of type kCFNumberLongLongType representing the file offset at which to start the transfer.

      Available in iOS 2.0 and later.

    • kCFStreamPropertyFTPAttemptPersistentConnection

      kCFStreamPropertyFTPAttemptPersistentConnection

      FTP Attempt Persistent Connection stream property key for set and copy operations. Set this property to kCFBooleanTrue to enable the reuse of existing server connections; set this property to kCFBooleanFalse to not reuse existing server connections. By default, this property is set to kCFBooleanTrue.

      Available in iOS 2.0 and later.

    • kCFStreamPropertyFTPProxy

      kCFStreamPropertyFTPProxy

      FTP 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.

    • kCFStreamPropertyFTPProxyHost

      kCFStreamPropertyFTPProxyHost

      FTP 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 kSCPropNetProxiesFTPProxy property defined in SCSchemaDefinitions.h.

      Available in iOS 2.0 and later.

    • kCFStreamPropertyFTPProxyPort

      kCFStreamPropertyFTPProxyPort

      FTP 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 kCFNumberIntType containing 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 the kSCPropNetProxiesFTPPort property defined in SCSchemaDefinitions.h.

      Available in iOS 2.0 and later.

    • kCFStreamPropertyFTPProxyUser

      kCFStreamPropertyFTPProxyUser

      FTP 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.

    • kCFStreamPropertyFTPProxyPassword

      kCFStreamPropertyFTPProxyPassword

      FTP 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.

    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.

  • FTP resource constants.

    Declaration

    Swift

    let kCFFTPResourceMode: CFString! let kCFFTPResourceName: CFString! let kCFFTPResourceOwner: CFString! let kCFFTPResourceGroup: CFString! let kCFFTPResourceLink: CFString! let kCFFTPResourceSize: CFString! let kCFFTPResourceType: CFString! let kCFFTPResourceModDate: CFString!

    Objective-C

    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

    • kCFFTPResourceMode

      kCFFTPResourceMode

      CFDictionary 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.

    • kCFFTPResourceName

      kCFFTPResourceName

      CFDictionary key for getting the CFString containing the name of the FTP resource.

      Available in iOS 2.0 and later.

    • kCFFTPResourceOwner

      kCFFTPResourceOwner

      CFDictionary key for getting the CFString containing the name of the owner of the FTP resource.

      Available in iOS 2.0 and later.

    • kCFFTPResourceGroup

      kCFFTPResourceGroup

      CFDictionary key for getting the CFString containing the name of a group that shares the FTP resource.

      Available in iOS 2.0 and later.

    • kCFFTPResourceLink

      kCFFTPResourceLink

      CFDictionary 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.

    • kCFFTPResourceSize

      kCFFTPResourceSize

      CFDictionary key for getting the CFNumber containing the size in bytes of the FTP resource.

      Available in iOS 2.0 and later.

    • kCFFTPResourceType

      kCFFTPResourceType

      CFDictionary 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.

    • kCFFTPResourceModDate

      kCFFTPResourceModDate

      CFDictionary key for getting the CFDate containing the last date and time the FTP resource was modified.

      Available in iOS 2.0 and later.

    Discussion

    The values of FTP resource keys are extracted from a line of the directory list by the CFFTPCreateParsedResourceListing function.

  • Error domains specific to CFFTPStream calls.

    Declaration

    Swift

    let kCFStreamErrorDomainFTP: Int32

    Objective-C

    extern const SInt32 kCFStreamErrorDomainFTP;

    Constants

    • kCFStreamErrorDomainFTP

      kCFStreamErrorDomainFTP

      Error domain that returns the last result code returned by the FTP server.

      Available in iOS 2.0 and later.

    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.