4D Internet Commands v14

FTP_MacBinary

Home

 
4D Internet Commands v14
FTP_MacBinary

FTP_MacBinary 


 

FTP_MacBinary ( ftp_ID ; macBinaryMode ) -> Function result 
Parameter Type   Description
ftp_ID  Longint in Reference to a FTP login
macBinaryMode  Integer in -1 = Get Current setting, 1 = Enable, 0 = Disable
in Current setting (if -1 passed)
Function result  Integer in Error Code

The FTP_MacBinary command enables/disables the MacBinary mode setting for FTP transfers using FTP_Send and FTP_Receive. Given a current FTP session identified by ftp_ID, this command will either turn MacBinary transfers on or off depending on the value passed in the macBinaryMode parameter.

The MacBinary protocol is often used by Macintosh FTP clients and servers to facilitate the transfer of binary data or files that contain both data and resource forks.

Note for Windows users: It is possible to use the MacBinary protocol for FTP transfers in a Windows environment however it should be noted that it may often not make sense to decode a MacBinary file on a PC computer. Intel-based machines cannot store files containing both data and resource forks. Since such a file format is foreign to the PC platform, Macintosh files which contain a resource fork are likely to be corrupted if saved in an unencoded format.

ftp_ID is the long integer reference to the FTP session established with FTP_Login.

macBinaryMode is integer parameter indicating whether to turn MacBinary transfers on or off. This value should be passed as a variable so the command can return the state of MacBinary transfers after the attempted change. Passing a 1 will enable MacBinary and a zero will disable. A -1 value in the parameter will cause the command to return in the macBinaryMode parameter the current state of MacBinary transfers (1 or zero).

Warning: Not all FTP servers support the MacBinary protocol, in this case the error 10053 is returned at each FTP_MacBinary command call, whatever the value of the macBinaryMode parameter. Previously described behaviours become false.

Example  

This example enables the MacBinary protocol before receiving an FTP file. If the file was successfully received with MacBinary turned on then it is decoded into its original format and the MacBinary document is deleted.

 vUseMacBin:=-1
 $error:=FTP_MacBinary(vFTP_ID;vUseMacBin)
 If($error=10053)
    MacBinaryIsSupported:=False `Ftp server doesn't support the MacBinary protocol
 Else
    MacBinaryIsSupported:=True
 End if
 
 
 vLocalFile:=""
 If(MacBinaryIsSupported)
    vUseMacBin:=1
    $error:=FTP_MacBinary(vFTP_ID;vUseMacBin`Try to turn MacBinary on for the download
 End if
 $error:=FTP_Receive(vFTP_ID;"MyApplication";vLocalFile;cbShowTherm)
 If($error=0)&(vUseMacBin=1) `If received OK and the file is in MacBinary format
    vDecodePath:=""
    If(IT_Decode(vLocalFile;vDecodePath;8)=0) `MacBinary decode
       DELETE DOCUMENT(vLocalFile`If sucessful decode of source, then delete it.
    End if
 End if

 
PROPERTIES 

Product: 4D Internet Commands
Theme: IC File Transfer
Number: 88938

 
HISTORY 

Created: 4D Internet Commands 6.5

 
SEE ALSO 

IT_Decode

 
ARTICLE USAGE

4D Internet Commands ( 4D Internet Commands v11.4)
4D Internet Commands ( 4D v13.2)
4D Internet Commands ( 4D Internet Commands v12.1)
4D Internet Commands ( 4D Internet Commands v14 R2)
4D Internet Commands ( 4D Internet Commands v14)
4D Internet Commands ( 4D Internet Commands v14 R3)
4D Internet Commands ( 4D Internet Commands v14 R4)