KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Converting an object type for an FTP directory item into the text description
PRODUCT: 4D Internet Commands | VERSION: | PLATFORM: Mac & Win
Published On: November 8, 2002
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Compatibility: 6.7.x and 6.8.x

Normally, when executing command FTP_GetDirList, the type of each object is returned as a numeric ID. Here is a simple method that will convert all IDs into a text description for each object.

` Project Method: FTP_TypeToText
` $1 – pointer to an array of longint that contains numeric ID of object types
` $2 – pointer to an array of text with the same size as $1

C_POINTER($1;$2)
C_LONGINT($Max)
$Max:=Size of array($1->)
For ($i;1;$Max)
 Case of
  : ($1->{$i}=0)
  $2->{$i}:="File"
  : ($1->{$i}=1)
  $2->{$i}:="Directory"
  : ($1->{$i}=2)
  $2->{$i}:="Block-type special file"
  : ($1->{$i}=3)
  $2->{$i}:="Character-type special file"
  : ($1->{$i}=4)
  $2->{$i}:="symbolic link (aliases on files or folders)"
  : ($1->{$i}=5)
  $2->{$i}:="FIFO special file"
  : ($1->{$i}=6)
  $2->{$i}:="AF_UNIX address family socket"
 End case
End for

Here is an example of the method call to this method:

$err:=FTP_GetDirList (vFTP_ID;$directory;atNames;alSizes;aIKinds;adModDates)
If ($err=0)
ARRAY TEXT(atKinds;Size of array(aIKinds))
FTP_TypeToText (->aIKinds;->atKinds)
End if

Once the project method FTP_TypeTOText is executed, atKinds will contain the text description type of each object.