SecureBlackbox 16: Why is the year reported incorrectly in directory listings?
Note: This article applies only to SecureBlackbox Legacy. For future development please consider using the latest version.
The FTPS protocol doesn't have a standard format for directory listings (see the exception below). Many modern FTP systems use the so-called Unix listing format produced on Unix-based systems by the "ls" tool. This listing specifies the year only when the file is X days or more away from the current moment. If the file is closer to today than X days, then the time is listed instead and the year is omitted.
And herein lies the problem: The X is different on different systems. Some systems have X set to +/-183 days (i.e., 6 months in the past and 6 months in the future) while others have X set to -365 days. There is no way to know how this X is set on the remote system. SecureBlackbox uses the Linux approach with +/-183 days. macOS uses -365 days and there can be other combinations as well.
Example: If today is the 1st of July 2015 and the listing date is "19th of November" — is it 19 Nov 2015 or 19 Nov 2014? (Future dates are possible for files, yes?) The answer depends on the value of X. If X = +/-183 then it's November 2015, and if the value of X is -365 then it's November 2014.
In general, if you don't like how the ParseFileListEntry procedure works in the component, you can implement your own, more precise, parsing — that's all we can offer.
To address the problem, there was an MLST/MLSD extension introduced. It is supported by some but not all servers. The extension means that there are MLST and MLSD commands supported, and those commands produce results in a well-defined uniform format suitable for machine parsing.
If your server supports this extension, you can make use of the MLSD method to get the corresponding listings.
Additionally, there's a ListDirectory method in the recent versions of SecureBlackbox, which automatically chooses what command to use for the listing, so if MLSD is supported, you'll get correct listings with it.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at firstname.lastname@example.org.