FTP_MacBinary

4D - Documentation   Français   English   German   Japanese   4D Internet Commands, Theme List   4D Internet Commands, Alphabetical List   Back   Previous   Next

version 6.5


FTP_MacBinary (ftp_ID; macBinaryMode) Integer

ParameterTypeDescription
ftp_IDLongintReference to a FTP login
macBinaryModeInteger-1 = Get Current setting, 1 = Enable, 0 = Disable
Current setting (if -1 passed)
Function resultIntegerError Code

Description

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   

See Also

IT_Decode.


4D - Documentation   Français   English   German   Japanese   4D Internet Commands, Theme List   4D Internet Commands, Alphabetical List   Back   Previous   Next