 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Marco antonio Guest
|
Posted: Sat Mar 06, 2004 9:37 pm Post subject: File create date TIdFTP |
|
|
As I can catch the date of creation of an archive for the TIdFTP
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Mar 06, 2004 11:07 pm Post subject: Re: File create date TIdFTP |
|
|
"Marco antonio" <nao (AT) nao (DOT) com> wrote
| Quote: | As I can catch the date of creation of an archive for the TIdFTP
|
You cannot. The FTP protocol does not provide anything for that. The best
you can get is the modified date, via the TIdFTPListItem.ModifiedDate
property when performing a directory listing.
Gambit
|
|
| Back to top |
|
 |
J. Peter Mugaas Guest
|
Posted: Sat Mar 06, 2004 11:37 pm Post subject: Re: File create date TIdFTP |
|
|
On Sat, 6 Mar 2004 18:37:51 -0300, Marco antonio wrote:
| Quote: | As I can catch the date of creation of an archive for the TIdFTP
|
The most accurate way to do this is to use the MDTM command. It should be
easy enough to add support for it Indy 9.0. Indy 10 already supports that
command.
For Indy 9.0, you might want to add this stuff:
function FTPMLSToGMTDateTime(const ATimeStamp : String):TDateTime;
var LYear, LMonth, LDay, LHour, LMin, LSec, LMSec : Integer;
LBuffer : String;
begin
Result := 0;
LBuffer := ATimeStamp;
if LBuffer <> '' then
begin
// 1234 56 78 90 12 34
// ---------- ---------
// 1998 11 07 08 52 15
LYear := StrToIntDef( Copy( LBuffer,1,4),0);
LMonth := StrToIntDef(Copy(LBuffer,5,2),0);
LDay := StrToIntDef(Copy(LBuffer,7,2),0);
LHour := StrToIntDef(Copy(LBuffer,9,2),0);
LMin := StrToIntDef(Copy(LBuffer,11,2),0);
LSec := StrToIntDef(Copy(LBuffer,13,2),0);
Fetch(LBuffer,'.');
LMSec := StrToIntDef(LBuffer,0);
Result := EncodeDate(LYear,LMonth,LDay);
Result := Result + EncodeTime(LHour,LMin,LSec,LMSec);
end;
end;
function FTPMLSToLocalDateTime(const ATimeStamp : String):TDateTime;
begin
Result := 0;
if ATimeStamp <> '' then
begin
Result := FTPMLSToGMTDateTime(ATimeStamp);
// Apply local offset
Result := Result + OffSetFromUTC;
end;
end;
function TIdFTP.FileDate(const AFileName: String;
const AsGMT: Boolean): TDateTime;
var LBuf : String;
begin
//Do not use the FEAT list because some servers
//may support it even if FEAT isn't supported
if SendCmd('MDTM ' + AFileName) = 213 then {do not localize}
begin
LBuf := LastCmdResult.Text[0];
LBuf := Trim(LBuf);
if AsGMT then
begin
Result := FTPMLSToGMTDateTime(LBuf);
end
else
begin
Result := FTPMLSToLocalDateTime(LBuf);
end;
end
else
begin
Result := 0;
end;
end;
One note that I should make is this, there are a few servers that have
buggy implementations of the MDTM command.
--
J. Peter Mugaas - Indy Pit Crew
Internet Direct (Indy) Website - http://www.nevrona.com/Indy
Personal Home Page - http://www.wvnet.edu/~oma00215
If I want to do business with you, I will contact you. Otherwise, do not
contact me.
|
|
| Back to top |
|
 |
J. Peter Mugaas Guest
|
Posted: Sat Mar 06, 2004 11:50 pm Post subject: Re: File create date TIdFTP |
|
|
On Sat, 6 Mar 2004 15:07:42 -0800, Remy Lebeau (TeamB) wrote:
| Quote: | [snip]
You cannot. The FTP protocol does not provide anything for that. The best
you can get is the modified date, via the TIdFTPListItem.ModifiedDate
property when performing a directory listing.
I beg to differ with you. Many servers support a MDTM command which is |
supposed to return a timestamp based on GMT. I have already some code that
may be helpful for Indy 9.
There are several problems with your suggested solution:
1) Some directory lists are provided in the server's local time zone and
you may not know what time zone that really is. That is problematic when
date comparisons with a value based on your time-zone.
2) Most Unix servers do not report a time value for a file over 6 months
old. Thus, if you downloaded a file 7 months ago and later that I updated
it. Seven months later, you may NOT even see that I had updated that file.
3) A few servers do not report a date at all. Indy 10 already supports a
few formats from these servers.
--
J. Peter Mugaas - Indy Pit Crew
Internet Direct (Indy) Website - http://www.nevrona.com/Indy
Personal Home Page - http://www.wvnet.edu/~oma00215
If I want to do business with you, I will contact you. Otherwise, do not
contact me.
|
|
| Back to top |
|
 |
Ben Hochstrasser Guest
|
Posted: Sun Mar 07, 2004 12:45 am Post subject: Re: File create date TIdFTP |
|
|
J. Peter Mugaas wrote:
| Quote: | I beg to differ with you. Many servers support a MDTM command which
is supposed to return a timestamp based on GMT. I have already some
code that may be helpful for Indy 9.
|
The original question dealt with the /creation/ date. What (if at all) an
FTP server shows is the /last modification/ date (which may or may not be
identical with the file creation date)
--
Ben
|
|
| Back to top |
|
 |
Vic Peters Guest
|
Posted: Fri May 21, 2004 2:23 pm Post subject: Re: File create date TIdFTP |
|
|
Hi Peter,
In this post you said, "Many servers support a MDTM command which is
supposed to return a timestamp based on GMT. I have already some code that
may be helpful for Indy 9."
Could you please share that code with us?
Vic
"J. Peter Mugaas" <oma00215 (AT) mail (DOT) wvnet.edu> wrote
| Quote: | On Sat, 6 Mar 2004 15:07:42 -0800, Remy Lebeau (TeamB) wrote:
[snip]
You cannot. The FTP protocol does not provide anything for that. The
best
you can get is the modified date, via the TIdFTPListItem.ModifiedDate
property when performing a directory listing.
I beg to differ with you. Many servers support a MDTM command which is
supposed to return a timestamp based on GMT. I have already some code
that
may be helpful for Indy 9.
There are several problems with your suggested solution:
1) Some directory lists are provided in the server's local time zone and
you may not know what time zone that really is. That is problematic when
date comparisons with a value based on your time-zone.
2) Most Unix servers do not report a time value for a file over 6 months
old. Thus, if you downloaded a file 7 months ago and later that I updated
it. Seven months later, you may NOT even see that I had updated that
file.
3) A few servers do not report a date at all. Indy 10 already supports a
few formats from these servers.
--
J. Peter Mugaas - Indy Pit Crew
Internet Direct (Indy) Website - http://www.nevrona.com/Indy
Personal Home Page - http://www.wvnet.edu/~oma00215
If I want to do business with you, I will contact you. Otherwise, do not
contact me.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|