Command MLST for FTP

720 views
Skip to first unread message

rafa thefull

unread,
May 9, 2012, 12:59:58 PM5/9/12
to harbou...@googlegroups.com
I found problemn using method o:listFiles()

The problem is sometimes attributes date or time is blank!!
For examples diferents years in the files in directory;

The solution is using command MLST, when get attributes exact of
directory / file;


METHOD MLST( cSpec ) CLASS tIPClientFTP

LOCAL cStr

DEFAULT cSpec TO ""

::InetSendAll( ::SocketCon, "MLST " + cSpec + ::cCRLF )
cStr := ::super:Read( 512 )

RETURN cStr


Examples;

? oFtp:MLST( "example.exe" )

Output:
250-Listing /UPDATES
Type=file;Size=7050752;Modify=20120509080534;Win32.ea=0x00000020;
example.exe
250 End.

It's possible add this patch ?

More info;
http://tools.ietf.org/html/rfc3659

Thank you
Regards

Klas Engwall

unread,
May 9, 2012, 7:07:56 PM5/9/12
to harbou...@googlegroups.com
Hi Rafa,

> I found problemn using method o:listFiles()
>
> The problem is sometimes attributes date or time is blank!!
> For examples diferents years in the files in directory;

The problem is that the output of the LIST command is not standardized,
so different FTP servers return differently formatted LIST results. It
is then up to the client to interpret all the different versions of the
result in a consistent way. And ListFiles() is not very good at that.

You can improve it by writing your own tIPClientFTPLocal class that
inherits from tIPClientFTP and replaces the ListFiles() method with a
better one. If you are satisfied with the rest of tIPClientFTP, you can
limit your local class to only that method.

I found that the part of ListFiles() that handles empty entries in the
<aList> array does not work because it deletes such entries and then
skips parsing the next entry (!). So the FOR EACH loop should be run
DESCEND instead of top to bottom. I also had to add a special case that
handles oddly formatted subdirectory names from one specific FTP server.
You may need additional workarounds depending on the FTP servers you
connect to. I can post the changes I made to ListFiles() if you like.

> The solution is using command MLST, when get attributes exact of
> directory / file;

MLST is an extension that is not supported everywhere, so you should
first check if it exists with the FEAT command. Once you have subclassed
tIPClientFTP, you can easily add FEAT and MLST and whatever else you
need to the subclass. But don't count on always being able to use MLST.
The owner/developer of the FTP server might not have implemented it.

> More info;
> http://tools.ietf.org/html/rfc3659

And FEAT is described there too.

Regards,
Klas

rafa thefull

unread,
May 10, 2012, 3:38:39 AM5/10/12
to harbou...@googlegroups.com
El 10/05/2012 1:07, Klas Engwall escribi�:
Hi Klas,

>> The solution is using command MLST, when get attributes exact of
>> directory / file;
>
> MLST is an extension that is not supported everywhere, so you should
> first check if it exists with the FEAT command. Once you have
> subclassed tIPClientFTP, you can easily add FEAT and MLST and
> whatever else you need to the subclass. But don't count on always
> being able to use MLST. The owner/developer of the FTP server might
> not have implemented it.
>

That is not supported by some servers does not mean that we can add
these features to the class.

This shall enable users to connect to servers if they are supported.

FTP Server Software with MLST/MLSD Support;

NetBSD-ftp, NcFTPD, Titan Server / Visinetic, SurgeFTP, Globalscape
Secure FTP Server, PureFTPd, WFTPD, RaidenFTPd 2.4 build 800+, gene6
3.x, proftpd, drftpd, Serv-U


> And FEAT is described there too.
Thanks for info!
Regards

Klas Engwall

unread,
May 10, 2012, 12:35:39 PM5/10/12
to harbou...@googlegroups.com
Hi Rafa,

>>> The solution is using command MLST, when get attributes exact of
>>> directory / file;
>>
>> MLST is an extension that is not supported everywhere, so you should
>> first check if it exists with the FEAT command. Once you have
>> subclassed tIPClientFTP, you can easily add FEAT and MLST and
>> whatever else you need to the subclass. But don't count on always
>> being able to use MLST. The owner/developer of the FTP server might
>> not have implemented it.
>
> That is not supported by some servers does not mean that we can add
> these features to the class.

Of course not. I only said that you must first check with FEAT before
using MLST.

But to make any changes to the official tIP classes you will have to
find someone who is interested in making those changes and committing
them. In the mean time you can easily extend tIPClientFTP yourself by
subclassing it.

Regards,
Klas
Reply all
Reply to author
Forward
0 new messages