1
1

The documentation in section about Ftp::GetNameList() method says:

Actual behaviour of NLST command varies from server to server, because the RFC is not clear in explaining what it should do. Some servers return the names of both files and directories, others return files only or even report error if the current directory is empty. Using GetList is a better choice in most cases.

Is this right? The rfc says

Since the information on a file may vary widely from system to system, …

about LIST command, and the result of NLST command is simple:

The server will return a stream of names of files and no other information …

What the better (works on a lot of servers) way to get a file names and their sizes: GetList() or GetNameList() + GetFileSize()? I'm interesting about Ftp and Sftp.

asked 03 Aug '10, 14:12

_FRED_'s gravatar image

_FRED_
907
accept rate: 0%


FTP: NSLT

The situation with NLST seems to be clear and unambiguous ... but is not. Imagine the following command:

   NSLT dir

some servers respond with something like this

   file1
   file2

while other servers respond with different output

  dir/file1
  dir/file2

FTP: GetNameList + GetFileSize

GetNameList works almost universally. GetFileSize is not supported by some FTP servers. And in some FTP servers the SIZE commands returns 0 for directories (so it's hard to decide whether a FTP item is file or directory).

SFTP: GetNameList, GetList and GetRawList

There is only one method for getting a directory content in the SFTP protocol. Those three methods are provided only for convenience and in order to have API similar to FTP component.

Best way how to get a directory list

FTP:

The best way would be calling Ftp.GetList() and let the parser handle all problems. If the format cannot be parsed then call the Ftp.GetRawList and mail the output to support@rebex.net. We'll be happy to enhance the built-in parser so it can handle this new format.

You can also subscribe to FtpItem.ItemParse event and provide your own parser. Sample parser which processes *nix access rights can be found in Rebex FTP Console Client sample.

SFTP:

Sftp.GetList() should work everywhere.

link

answered 03 Aug '10, 15:08

Martin%20Vobr's gravatar image

Martin Vobr ♦♦
335310
accept rate: 37%

Thanks for the great answer!

(03 Aug '10, 15:38) _FRED_

Thanks. Good questions inspire good answers ;-)

(03 Aug '10, 15:48) Martin Vobr ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×136
×12
×2

Asked: 03 Aug '10, 14:12

Seen: 1,336 times

Last updated: 03 Aug '10, 15:08