🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
3 messages
3 total messages Started by Carl Danley Tue, 26 Jun 2007 19:19
Using the TIdFTP Component to produce a list of filenames only...
#1021
Author: Carl Danley
Date: Tue, 26 Jun 2007 19:19
17 lines
2007 bytes
Ok, I am using Borland C++ Builder 2006 with Indy 9... I am trying to 
implement a TIdFTP component into the program... I set permissions for the 
FTP account so that it can only see one folder on my FTP Server and all of 
its subfolders... I have also added a simple ListBox so that I can display 
the outcome of the List() function in it... I want to use the List() 
function to return a list of ONLY the filenames... Right now, I am getting 
all of this other stuff as well as the filenames... I created a 
bubble-sorting routine to filter ALL spaces out of the List() results... 
Everything worked fine until I tried filtering a name with spaces in it...
It filters like this:

unfiltered: my graduation.jpg
filtered: graduation.jpg

Is there anyway that I can implement something more simple to filter the 
filenames into a result that allows every filename possibility to be 
visible? 
Re: Using the TIdFTP Component to produce a list of filenames only...
#1022
Author: 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
Re: Using the TIdFTP Component to produce a list of filenames only...
#1023
Author: Carl Danley
Date: Tue, 26 Jun 2007 20:57
2 lines
1326 bytes
Thank you for your help! I implemented some coding and changed a few things 
and it worked perfectly! 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads