🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Indy 9 TIdFTP EIdConnClosedGracefully etc.... (repost)

#2095
From: Remy Lebeau (TeamB)
Date: Fri, 11 Aug 2006 18:06
111 lines
4384 bytes
"Skaarak" <skaarak@NOakamailSPAM.com> wrote in message
news:44dca1d2@newsgroups.borland.com...

> I've included the FormCreate function as well so you can see what's in it.

DO NOT use the OnCreate event in C++!  It is a Delphi idiom that produces
illegal behavior in C++ as it can be triggered before the constructor.  Use
the actual constructor instead.

> Stepping through the code I get to this line FTP2->List(RawDir->Items,"*",
> true); int the ParseDirectory function before it fails and throws the
Dialog Box.

Did you try putting try..catch blocks into your code yet?

    __fastcall TForm1::TForm1(TComponent *Owner)
        : TForm(Owner)
    {
        this->Left = 100;
        this->Top = 100;
        this->ClientWidth = 800;
        this->ClientHeight = 600;

        AnsiString temp;
        temp.printf("Interface Assistant v%d.%02d.%02d", MAJOR_VERSION,
MINOR_VERSION, VER_REV);
        this->Caption = temp;

        CurFile->Caption = "";
        Size->Caption = "";
        dt = NULL;

        SaveLoad (ID_LOAD);
    }

    void __fastcall TForm1::ConnectClick(TObject *Sender)
    {
        if( !FTP2->Connected() )
        {
            FTP2->Host = Server->Text;
            FTP2->Username = UserName->Text;
            FTP2->Password = AdminForm->Decode(Password->Text);
            try
            {
                FTP2->Connect(true, 5000);
                try
                {
                    FTP2->ChangeDir("AddOns");
                    if( !ParseDirectory(RemoteDir->Items, NULL, NULL,
true) )
                        ShowMessage("Parse Directory Error");
                }
                catch(const Exception &)
                {
                    FTP2->Disconnect();
                    throw;
                }
            }
            catch(const Exception &e)
            {
                ShowMessage(e.Message);
            }
        }
    }

    bool __fastcall TForm1::ParseDirectory(TStrings *name, TStrings
*directory, TStrings *size, bool dironly)
    {
        bool dir;
        AnsiString item, temp;
        RawDir->Clear();

        try
        {
            FTP2->List(RawDir->Items,"*", true);
        }
        catch(const Exception &)
        {
            return false;
        }

        for(int i = 0; i < RawDir->Count; ++i)
        {
            dir = false;
            item = RawDir->Items->Strings[i];

            temp = item.SubString(1, 10);    //directory
            if( (temp != "") && ((temp[1] == 'd') || (temp[1] == 'D')) )
                dir = true;
            if( (directory) && ((dir) || (!dironly)) )
                directory->Add(temp);

            temp = item.SubString(11, 16);    //Unknown

            temp = item.SubString(27, 16);    //Size
            if( (size) && ((dir) || (!dironly)) )
                size->Add(temp);

            temp = item.SubString(44, 12);    //Date

            temp = item.SubString(57, 99);    //Name
            if( (name) && ((dir) || (!dironly)) )
                name->Add(temp);
        }

        return true;
    }


Gambit
Technical Details
Message-ID: <44dcc77f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <44da0822$1@newsgroups.borland.com> <44da0c3a$1@newsgroups.borland.com> <44da527f@newsgroups.borland.com> <44da5f29$1@newsgroups.borland.com> <44da6c13$1@newsgroups.borland.com> <44da795d@newsgroups.borland.com> <44dbb9a3$1@newsgroups.borland.com> <44dbcbbb$1@newsgroups.borland.com> <44dca1d2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,cd863af49bc3aa8d
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <44da0822$1@newsgroups.borland.com> <44da0c3a$1@newsgroups.borland.com> <44da527f@newsgroups.borland.com> <44da5f29$1@newsgroups.borland.com> <44da6c13$1@newsgroups.borland.com> <44da795d@newsgroups.borland.com> <44dbb9a3$1@newsgroups.borland.com> <44dbcbbb$1@newsgroups.borland.com> <44dca1d2@newsgroups.borland.com>
Subject: Re: Indy 9 TIdFTP EIdConnClosedGracefully etc.... (repost)
Date: Fri, 11 Aug 2006 11:06:19 -0700
Lines: 113
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: 68.69.17.41
Message-ID: <44dcc77f$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1155319679 68.69.17.41 (11 Aug 2006 11:07:59 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail