Livecode Wiki
Advertisement

Switches between sending LIST or NLST formats when listing the contents of an FTP directory.

Syntax:

libURLSetFTPListCommand {"LIST" | "NLST"}

Examples:

libURLSetFTPListCommand "NLST"
libURLSetFTPListCommand (the listCommand of this card)

Use the libURLSetFTPListCommand command to get a simple list of files in an FTP directory.

After setting it, you can't use LibURLftpCommand, because it doesn't support LIST or simila commands. Instead use this code:

libURLSetFTPListCommand "LIST"
 put urlencode("user@aruba.it") into myUser
 put URL ("ftp://" &myUser& ":password@ftp.mysite.com/myfolder/")

The result will be something like:

drwxr-xr-x   19 18714984   users              33 Feb 28 01:12 .
dr-xr-xr-x    2 18714984   users               3 Feb 16  2015 ..
-rwxr-xr-x    1 18714984   users            2338 Aug  2  2011 Logo.jpg
drwxr-xr-x    6 18714984   users              14 Jun 19  2014 ale
drwxr-xr-x    2 18714984   users               8 Jan 31  2014 android
drwxr-xr-x    3 18714984   users              36 Jan 31 12:20 Folder1
drwxr-xr-x    4 18714984   users              55 May 14  2016 Images
-rwxr-xr-x    1 18714984   users            3150 Sep 23  2009 canvas.html 

A URL that ends with a slash (/) designates a directory (rather than a file). An ftp URL to a directory evaluates to a listing of the directory's contents. The format of a directory listing depends on which FTP command LiveCode sends to the FTP server. You specify which command to use with the libURLSetFTPListCommand command.

If you specify LIST, directory listings are returned in the same format as the Unix "ls" command and include information such as permissions, owner, size, and last modification date as well as the name of each file or subdirectory. Use this format if you need the additional information about each item in the directory.

If you specify NLST, directory listings consists of a list of names of files and subdirectories, one per line, without the additional information provided in a LIST listing. Use this format if you need a simple list of files and don't want to parse the more complex LIST listing for the file names.

The list command is set to LIST when the application starts up.

FTPservers are not uniform in their response to a request for a directory listing. Some servers may format directory listings differently from these descriptions. These are the most common formats, but they are not universal.

The libURLSetFTPListCommand command is part of the Internet library. To ensure that the command works in a standalone application, you must include this custom library when you create your standalone. In the Inclusions section of the Standalone Application Settings window, make sure "Internet Library" is selected in the list of script libraries.

See: internet library

Advertisement