FTP-клиент. Гайсина Л.Ф. - 30 стр.

UptoLike

Составители: 

30
Приложение А
(справочное)
Программный код
#include <vcl.h>
#pragma hdrstop
#include "UFtp.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int i,k=0;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
void __fastcall TForm1::ConnectClick(TObject *Sender)
{
try
{
f->Host=Edit1->Text;
f->Connect();
ll->Clear();
f->Nlist();
}
catch(ESockError&)
{
ShowMessage("Âîçìîæíî ïîäêëþ÷åíèå ïðîèçîøëî"
" èëè âû íå ïîäêëþ÷åíû ê ëîêàëüíîé ñåòè ");
}
}
void __fastcall TForm1::DisconnectClick(TObject
*Sender)
{
f->Disconnect();
}
void __fastcall TForm1::fListItem(AnsiString Listing)
{
ll->Items->Add(Listing);
}
void __fastcall TForm1::DownFClick(TObject *Sender)
{
if (f->Connected)
{
if (SaveDialog1->Execute())
{
if (ll->Items->Strings[ll->ItemIndex]!="")
{SaveDialog1->FileName=ll->Items->Strings[ll-
>ItemIndex];
f->Download(ll->Items->Strings[ll-
>ItemIndex],SaveDialog1->FileName);
}
}
} else ShowMessage("Ïîäêëþ÷åíèå íå ïðîèçîøëî");
}
void __fastcall TForm1::UploadClick(TObject *Sender)
{
String s,d,ff;
if (f->Connected)
{
if (oo->Execute())
{
d=oo->FileName;
for (i=d.Length(); i>=1 ; i--)
{if (d[i]!='\\')
{s+=d[i];} else {break;}
}
ff=s;
for (i=s.Length(); i>=1 ; i--)
{ff[s.Length()-i+1]=s[i];}
Edit3->Text=ff;
f->Upload(oo->FileName,ff);
ll->Items->Add(ff);
}
} else ShowMessage("Ïîäêëþ÷åíèå íå ïðîèçîøëî");
}
void __fastcall TForm1::DeleteFClick(TObject *Sender)
{
if (f->Connected)
{
if (ll->Items->Strings[ll->ItemIndex]!="")
{
f->Delete(ll->Items->Strings[ll->ItemIndex]);
ll->Items->Delete(ll->ItemIndex);
}
} else ShowMessage("Ïîäêëþ÷åíèå íå ïðîèçîøëî");
}
void __fastcall TForm1::llDblClick(TObject *Sender)
{
try
{
if (ll->Items->Strings[ll->ItemIndex]==".."){i=1;}
if (i!=0)
{
if (ll->Items->Strings[ll->ItemIndex]=="..") {k--;}
else {k++;}
f->ChangeDir(ll->Items->Strings[ll->ItemIndex]);
ll->Clear();
if (k!=0)
{ll->Items->Add("..");}
f->Nlist();
}
}
catch(...)
{
ShowMessage("Âîçìîæíî Âû ïûòàåòåñü 'çàéòè'"
" â ôàèë, ýòîãî íåëüçÿ, äëÿ ñêà÷èâàíèÿ íàæìèòå êíîïêó
'Ñêà÷àòü'");
}
}
void __fastcall TForm1::FormKeyPress(TObject
*Sender, char &Key)
{
if (Key==13)
{
llDblClick(Sender);
}
Лист
7
                                                       Приложение А
                                                       (справочное)
                                                     Программный код
                                                               {
                                                                d=oo->FileName;
#include 
                                                                for (i=d.Length(); i>=1 ; i--)
#pragma hdrstop
                                                                  {if (d[i]!='\\')
#include "UFtp.h"
                                                                      {s+=d[i];} else {break;}
#pragma package(smart_init)
                                                                  }
#pragma resource "*.dfm"
                                                                ff=s;
TForm1 *Form1;
                                                                for (i=s.Length(); i>=1 ; i--)
int i,k=0;
                                                                   {ff[s.Length()-i+1]=s[i];}
__fastcall TForm1::TForm1(TComponent* Owner)
                                                                Edit3->Text=ff;
        : TForm(Owner)
                                                                f->Upload(oo->FileName,ff);
{
                                                                ll->Items->Add(ff);
}
                                                               }
void __fastcall TForm1::ConnectClick(TObject *Sender)
                                                              } else ShowMessage("Ïîäêëþ÷åíèå íå ïðîèçîøëî");
{
                                                            }
  try
                                                            void __fastcall TForm1::DeleteFClick(TObject *Sender)
   {
                                                            {
     f->Host=Edit1->Text;
                                                             if (f->Connected)
     f->Connect();
                                                             {
     ll->Clear();
                                                             if (ll->Items->Strings[ll->ItemIndex]!="")
     f->Nlist();
                                                              {
   }
                                                               f->Delete(ll->Items->Strings[ll->ItemIndex]);
  catch(ESockError&)
                                                               ll->Items->Delete(ll->ItemIndex);
  {
                                                              }
    ShowMessage("Âîçìîæíî ïîäêëþ÷åíèå ïðîèçîøëî"
                                                             } else ShowMessage("Ïîäêëþ÷åíèå íå ïðîèçîøëî");
             " èëè âû íå ïîäêëþ÷åíû ê ëîêàëüíîé ñåòè ");
                                                            }
  }
                                                            void __fastcall TForm1::llDblClick(TObject *Sender)
}
                                                            {
void __fastcall TForm1::DisconnectClick(TObject
                                                             try
*Sender)
                                                             {
{
                                                                if (ll->Items->Strings[ll->ItemIndex]==".."){i=1;}
   f->Disconnect();
                                                                if (i!=0)
}
                                                                {
void __fastcall TForm1::fListItem(AnsiString Listing)
                                                                 if (ll->Items->Strings[ll->ItemIndex]=="..") {k--;}
{
                                                                   else {k++;}
   ll->Items->Add(Listing);
                                                                   f->ChangeDir(ll->Items->Strings[ll->ItemIndex]);
}
                                                                 ll->Clear();
void __fastcall TForm1::DownFClick(TObject *Sender)
                                                                 if (k!=0)
{
                                                                   {ll->Items->Add("..");}
 if (f->Connected)
                                                                 f->Nlist();
 {
                                                                }
  if (SaveDialog1->Execute())
                                                             }
   {
                                                             catch(...)
    if (ll->Items->Strings[ll->ItemIndex]!="")
                                                             {
      {SaveDialog1->FileName=ll->Items->Strings[ll-
                                                               ShowMessage("Âîçìîæíî Âû ïûòàåòåñü 'çàéòè'"
>ItemIndex];
                                                               " â ôàèë, ýòîãî íåëüçÿ, äëÿ ñêà÷èâàíèÿ íàæìèòå êíîïêó
       f->Download(ll->Items->Strings[ll-
                                                            'Ñêà÷àòü'");
>ItemIndex],SaveDialog1->FileName);
                                                             }
      }
                                                            }
   }
                                                            void __fastcall TForm1::FormKeyPress(TObject
 } else ShowMessage("Ïîäêëþ÷åíèå íå ïðîèçîøëî");
                                                            *Sender, char &Key)
}
                                                            {
void __fastcall TForm1::UploadClick(TObject *Sender)
                                                              if (Key==13)
{
                                                              {
  String s,d,ff;
                                                                llDblClick(Sender);
  if (f->Connected)
                                                              }
   {
    if (oo->Execute())



                                                                                                                    Лист

                                                                                                                7

 30