🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #1022

Re: Using the TIdFTP Component to produce a list of filenames only...

#1022
From: Remy Lebeau (TeamB)
Date: Tue, 26 Jun 2007 19:48
46 lines
2704 bytes
"Carl Danley" <cdanley@codebyter.com> wrote in message
news:468166da$1@newsgroups.borland.com...

> I want to use the List() function to return a list of ONLY the
filenames...

That is not how List() works.  To do what you are asking for, you will
have to call List() first to get ALL of the names, including
subfolders, and then use the DirectoryListing property to filter that
information further.

> Right now, I am getting all of this other stuff as well as the
filenames...

As you should be, because that is how FTP directory listings work to
begin with.

> I created a bubble-sorting routine to filter ALL spaces out of
> the List() results...

That is not necessary.  The DirectoryListing collection will tell you
exactly which items are files and which are subfolders.  For example:

    ListBox1->Items->Clear();
    IdFTP1->List(NULL, "");
    for(int i = 0; i < IdFTP1->DirectoryListing->Count; ++i)
    {
        TIdFTPListItem *Item = IdFTP1->DirectoryListing->Items[i];
        if( Item->ItemType == ditFile )
            ListBox1->Items->Add(Item->FileName);
    }

With that said, do keep in mind that FTP directory listing formats
were NOT standardized in the original FTP specification.  FTP
implementators can use whatever format they want, and clients have to
just deal with it as best they can.  TIdFTP in Indy 9 is hard-coded to
only support a few commonly used formats, but there are literally
dozens of different formats and variations floating around.  TIdFTP in
Indy 10 implements a new plugin architecture for parsing formats in a
more generic manner, and provides default parsers for most known
formats, as well as supports several new commands that were introduced
in later drafts to the FTP spec to standardize directory listings.


Gambit
Technical Details
Message-ID: <46816f95$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <468166da$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,191a22c3ac94f58b
X-Google-Attributes: gid11508e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <468166da$1@newsgroups.borland.com>
Subject: Re: Using the TIdFTP Component to produce a list of filenames only...
Date: Tue, 26 Jun 2007 12:48:49 -0700
Lines: 48
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 75.82.252.126
Message-ID: <46816f95$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1182887829 75.82.252.126 (26 Jun 2007 12:57:09 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail