cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

Re: Is there a CURLOPT_DIRLISTONLY option for SFTP?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 28 Jun 2010 23:15:38 +0200 (CEST)

On Mon, 28 Jun 2010, O'Loughlin, Anthony (H USA) wrote:

> I'm trying get a list of files only from a UNIX machine VIA SFTP. I'm using
> NLST in the CURLOPT_CUSTOMREQUEST option. I'm running this from Perl. When a
> get the list back it has "." (dot) and ".."(dotdot) as part of the list.
> Subdirectories are also included in the list. When I use FTP in place of
> SFTP everything works fine - I get back only the files. Is there a way to
> get back only the files and not the Subdirectories with SFTP?

Short answer: no

Longer answer:

In SFTP, the CURLOPT_DIRLISTONLY option is controlled entirely by libcurl code
so it would be possible to craft it to show exactly what we want. That could
very well exclude directories and only show files. But in reality, I would
rather that we instead document that this is how it works as we don't want to
break compatibility with existing apps that may depend on this functionality.

In FTP, there's just no way of knowing if you get only files or directories
too, as the original spec is very fuzzily written in this regard and I know
that different servers implment NLST differently so even if you now have found
this to work on one or more servers, there are unfortunately others out there
for which you will get different results back from!

Ideally, the (FTP) wildcard feature of libcurl should be brought to SFTP as
well...

Another, slightly less nice, option would be to introduce a new option that
would return the directory listing in a somewhat defined and documented way so
that an application would be able to reliably parse it.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-06-28

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET