Directory listing has NULs in it - so Indy cuts it off at first NUL

Giganews Newsgroups
Subject: Directory listing has NULs in it - so Indy cuts it off at first NUL
Posted by:  Dennis Wynne (dwyn…@equinoxis.com)
Date: Fri, 14 Jul 2006

Using Indy 10.1.5 in Delphi.

I am connecting to some "strange" FTP server that has a directory listing that is in no format I have seen - or other programs like WS_FTP can decode.

No problem, I think - I will parse the listing myself.

The trouble is the host is sending nulls in each line before the CR at the end of the line.  So what I get is like:

file_date file_time size_in_blocks file_name<some spaces><some nuls><CR>

FTP.List always returns 1 item as does FTP.ListResults . So no matter how many files there are, I can only "See" the first one.  On a long listing I can see the allocated memory go up as it collects the raw listing, but I can't access anything past the first item.

Short of having to do the work myself (sending the LIST command and capturing the raw data, then parsing) is there any way to have Indy return all the raw data to me?  If so, I can easily parse it and remove the NULs and get the info I need.

Looking at the source ldest is declared as a tldStringStream for InternalGet() to place the results of the command, and this is then assigned to FlistResult.Text . I assume that the data is getting truncated at this assign when it tries to parse the long data into strings and set count - it his the NUL and stops with a count of 1?

So is there a why to get the LIST result in its ture RAW format?

Thanks!
Dennis

Replies