I want to download files only if they have been modified on the server by comparing the date and time. How do I do this with Indy?
|Previous Top Next|
The best way to compare the date and time is to use the MDTM FTP command. This FTP command will give the last modified date stamp based on Universal time. This will only work if the FTP server supports the MDTM command.
Indy 9.0 does not support MDTM although the functionality is easy to add. The MDTM command is documented in the an IETF draft titled Extensions to FTP.
Indy 10 has support for MDTM in the TIdFTP.FileDate method.
There are some unreliable ways that files are sometimes synchronized between a server and client. We do not recommend these at all and mention them only to discuss their problems.
Some clients might attempt to use a date and time given by the server in the output from the list command. This is problematic for several reasons.
|•||Many servers will give timestamps relative to their local time-zone. Unfortunately, you may always know what that time zone is for comparisons and if you did know, you would have to convert the time into the user's local time-zone for accuracy. The only list formats that give time-stamps based on Universal Time (in the U.S., commonly known as Greenwhich Mean Time) are EPLF (Easily Parsed List Format), and Distinct FTP Server plus the output from the MLST or MLSD commands.|
|•||Novell Netware and Unix (including systems emulating the Unix directory listing format) will either report either a year or a time but not both. Novell Netware only reports a time for files less than one year old. Most Unix servers only give a time stamp when a file is less than 6 monthes old and unfortunately, this behavior has to be emulated by a majority of FTP servers in use today just to work with web-browsers and a vast majority of FTP code. Serv-U, some FreeBSD systems, and Indy 10's FTP Server component support a -T switch for getting a complete timestamp with the LIST command but that is still based on the local time-zone, is not supported by most FTP servers, and other Unix systems may treat the -T switch far differently than FreeBSD.|
|•||A few FTP servers may not give a date in their FTP directory listings at all. This includes Xercom MicroRTOS, HP3000, Cisco IOS, TOPS20, IBM MVS JES interfaces, and VSE Power Queues and VSE root directories.|
|•||There are still many servers in use that do not support the MLST and MLSD commands.|
Some clients might use file sizes given by the directory listing to determine if a file was modified. This is problematic for the reasons given in the Knowlege Base item, "How do I obtain the size of a file I am about to download with TIdFTP?"