curl-library
Re: libcurl FTP - directory listing by file mask
Date: Fri, 28 Mar 2008 08:37:26 +0000
On Fri, Mar 28, 2008 at 12:29:04AM -0700, Dan Fandrich wrote:
> On Thu, Mar 27, 2008 at 04:47:56PM -0400, Alla Bogolubov wrote:
> > What is the way to request a directory listing by file mask? Is there a way to
> > receive listing of ?*.txt? files using CURLOPT_DIRLISTONLY?
>
> Hmmm, I just took a look at the code and it looks like there isn't a way.
> Just how would such a feature work? How would you be able to tell the
> difference between, for example, downloading a file called "*.txt" (it's a
> legal name on UNIX) and doing a wildcard directory listing? Unless wildcards
> were enabled only when CURLOPT_DIRLISTONLY is set--that might work, although
> it's then a bit inconsistent.
At the moment there is an inconsitency using the -l/--list-only ftp option (curl command), as this seems to be ignored for files. Maybe if the -l option was used with a filename it would be logical to make this similar to an 'ls' command, so file name could be treated as a regex? This would be of particular use with the command, but would also make life easier for library users. A regex would need additional libraries, but simple '*' and '?' matching could be handled internally.
At the moment I download the directory listing and parse that using a regex outside of curl, but I can see it would be a common requirement. It may of course need a new option for backward compatibility.
Cheers
Mike
Received on 2008-03-28