Why is the year reported incorrectly in directory listings?

FTPS protocol doesn't have a standard format for directory listings (see the exception below). Many modern FTP systems use so-called Unix listing format produced on Unix-based systems by "ls" tool. This listing specifies the year only when the file is X days or more away from current moment. If the file is closer to today than X days, then the time is listed instead and the year is omitted.

And here comes 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 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 use Linux approach with +/-183 days. MacOS X 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 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 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.

Ready to get started?

Learn more about SecureBlackbox or download a free trial.

Download Now