Board index » delphi » FTP Listing Files, Parsing Results

FTP Listing Files, Parsing Results


2004-11-30 03:45:33 AM
delphi115
Indy 10
I am getting a list of files using Indy 10's TidFTP and it works fine. But I
would like to get the date from the results. The string only contains the
mmm dd value, nothing for year. Also, are there rules on how to parse the
results form a .List command?
Thanks
Ed Dressel
 
 

Re:FTP Listing Files, Parsing Results

"Ed Dressel" <none>writes
Quote
I would like to get the date from the results. The string only
contains the mmm dd value, nothing for year.
Why are you operating on strings and not using the DirectoryListing
collection instead? TIdFTPListItem has a ModifiedDate property which is a
TDateTime instead of a string.
Quote
Also, are there rules on how to parse the results form a .List command?
That is completely dependant on the particular format used for formatting
the data. There are literally dozens of formats used on the Internet today,
and none of them are standardized. That is why TIdFTP implements the
DirectoryListing collection in the first place - to standardize the
non-standard data. There are dozens of parser classes provided in Indy 10
that plug into the DirectoryListing architecture for automating the parsing
for you.
Gambit
 

Re:FTP Listing Files, Parsing Results

Hi remy, while we are on the subject of Ftps, what are the things to be
carefull about when puytting a FtpClient in a thread ??
Thanks,
CheGueVerra
PS. Anyone else can answer too :P
 

Re:FTP Listing Files, Parsing Results

"CheGueVerra" <XXXX@XXXXX.COM>writes
Quote
Hi remy, while we are on the subject of Ftps, what are
the things to be carefull about when puytting a FtpClient
in a thread ??
That is not the same issue being discussed in this thread. You should
always start a new discussion thread when changing the topic of discussion.
This newsgroup is publically archived and searchable. Changing the topic
mid-thread deminishes the effectiveness of such an archive.
Please see the recent "Indy: Threaded FTP uploads" discussion in this same
newsgroup.
Gambit
 

Re:FTP Listing Files, Parsing Results

Meh is sorry....
CheGueVerra
 

Re:FTP Listing Files, Parsing Results

On Mon, 29 Nov 2004 11:45:33 -0800, Ed Dressel writes:
Quote
Indy 10

I am getting a list of files using Indy 10's TidFTP and it works fine. But I
would like to get the date from the results. The string only contains the
mmm dd value, nothing for year.
That is the case with the Unix directory listing format. That comes from
FTP servers that simply piped output from the /bin/ls command. bin/ls will
return a year for files that are greater than six months old or a time if
it's less than six months old (that's an OpenGroup standard that most
Unix-like operating systems follow).
Quote
Also, are there rules on how to parse the
results form a .List command?

No, there are none because there is no such thing as a RFC standard listing
format. Programmers are free to do as they will and they did. Right now,
I have a complete collection of various FTP list samples I have gathered over
2 years that prove this point. DIrectoryListing is an attempt to try to
make things easier for you. The way it works is though a series of parsing
classes. Each class will scan the output and determine if it can parse the
data. If a class is found that will parse the data, it is that class that
processes the data. The classes work through a self-registration scheme so
that a reference to the class will cause it to be linked into your program.
To make that easier for you, there is a special IdAllFTPListParsers unit
you can add that will cause all of the parsers to be added to your program.
We add more parsers over time and I checked in three last night based on
some FTP listing data I had stumbled across. If there's a listing format
you need Indy to support, you may want to consider sending me a few sample
lists and I may see what I do.
It's a very complex design for a very complex problem. As far as your
question about dates, there is no standard at all and there are some
listing formats that will NOT provide a Modified Date at all (ModifiedAvail
= False). that is why I am strongly apposed to using the date from the dir
listing to synchronize files and that is especially true because often dates
are givin in the server's local time zone and you will often NOT know what
is. There are only three directory listing formats where a date is in GMT
(output from the MLST command, the listing format used by Distinct's FTP
server, and something called EPLF - cr.yp.to/ftp/list/eplf.html).
You can not use size either because that is sometimes not accurate and some
parsers can only estimate a possible size. A few parsers are unable to get
a file size from a server at all (SizeAvail = False).
I know I have gone quite a bit. it is a nightmare and that is why I
personally am such a big fan of some new FTP commands called MLST and MLSD.
Those are defined in
www.ietf.org/internet-drafts/draft-ietf-ftpext-mlst-16.txt and I
love those commands because there is a standard listing format. You can
take advantage of this by setting IdFTP.UseMLS to true and if the server
will support those commands. I wish more FTP servers would support this
new feature.
--
J. Peter Mugaas - Indy Pit Crew
Internet Direct (Indy) Website - www.indyproject.org/
Personal Home Page - www.wvnet.edu/~oma00215
If I want to do business with you, I will contact you. Otherwise, do not
contact me.
 

Re:FTP Listing Files, Parsing Results

<snip>
Thanks
Ed Dressel
 

Re:FTP Listing Files, Parsing Results

Quote
Why are you operating on strings and not using the DirectoryListing
collection instead?
'cause I didn't know about it. :-)
Thanks for the heads up.
Ed Dressel
 

Re:FTP Listing Files, Parsing Results

Quote
>Why are you operating on strings and not using the DirectoryListing
>collection instead?
'cause I didn't know about it. :-)
Thanks for the heads up.
Because of all the changes to TIdFTP in Indy 10, a lot of effort was put into better documenting it. ;) it is a little light on the implementation of the many (many, many) parser classes... but it is pretty decent for the PMEs in TIdFTP.