views:

129

answers:

1

I have a simple problem. My (Delphi 2007 with Indy 9) application connects to an FTP server to retrieve a list of files. (NLST, not LIST) I then download every file separately for further processing.

Unfortunately, the administrators of the FTP site added a subfolder in the folder where the files are located. The current code thinks it's a file, thus it tries to download it. This fails, of course. Right now, I just solved it by checking if the process succeeded or not and if not, it will add a message to the error log but it also continues processing other files.

But what I would like to do is add some code which will check first if the name in the filelist is a filename or foldername. What's the easiest way to do this?

Note: I cannot rely on the LIST method to return a file list with additional attributes since I'm connecting to multiple FTP servers which could all define their own file format. Besides, parsing such a list isn't a very easy task, even if I could determine which kind of list the FTP server returns. To make matters worse, some of the filenames are just numbers with no extension so wildcards don't help either.

+1  A: 

The NLST command does not deliver any details about the names it provides, by design. You must use the LIST or MLSD/MLST command to get details so you can differentiate between different item types. Yes, when using LIST, there are many many different formats used online and you would have to detect and decode them manually as needed (for instance, the TIdFTP component in Indy 10 has several dozen parsers inplemented for exactly that purpose). That is why the MLST/MLST extension was invented. It is specifically designed to have a unified format that is easily parsed in code without any guesswork. Many modern FTP servers support that extension.

Remy Lebeau - TeamB
Unfortunately, a few FTP servers that I connect to are a bit old and don't support MLST. The upgrade to Indy 10 might work but hasn't been done because the current code is depending on several Indy 9 features that 10 doesn't support or supports in a different way. So far, this seems to be the best solution, though...
Workshop Alex
What features do you need from Indy 9 that do not work in Indy 10?
Remy Lebeau - TeamB
They're not really missing but there's a lot of code that would need to be refactored, then test again with Indy 10. We can fix it, but it takes time. I'm trying to stay within the budget that was allocated for the project. :-)
Workshop Alex