Autor Beitrag
F.Art
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 434



BeitragVerfasst: Do 14.10.04 15:23 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPServer, IdFTPServer, idFTPList;

type
  TForm1 = class(TForm)
    IdFTPServer: TIdFTPServer;
    procedure IdFTPServerUserLogin(ASender: TIdFTPServerThread;
      const AUsername, APassword: String; var AAuthenticated: Boolean);
    procedure IdFTPServerListDirectory(ASender: TIdFTPServerThread;
      const APath: String; ADirectoryListing: TIdFTPListItems);
    procedure IdFTPServerChangeDirectory(ASender: TIdFTPServerThread;
      var VDirectory: String);
    procedure IdFTPServerMakeDirectory(ASender: TIdFTPServerThread;
      var VDirectory: String);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.IdFTPServerUserLogin(ASender: TIdFTPServerThread;
  const AUsername, APassword: String; var AAuthenticated: Boolean);
begin
  AAuthenticated := ( AUsername = 'test' ) and ( APassword = '123' ) ;
  if not AAuthenticated then exit;
  ASender.HomeDir := 'D:\';
  ASender.CurrentDir := 'D:\';
end;

procedure TForm1.IdFTPServerListDirectory(ASender: TIdFTPServerThread;
  const APath: String; ADirectoryListing: TIdFTPListItems);
var LItem: TidFTPListItem;
    tmp1: TSearchRec;
    LFileAttribute: Integer;
    LPfad: String;
begin
  LPfad := 'D:\';
  LFileAttribute := FILE_ATTRIBUTE_DIRECTORY + FILE_ATTRIBUTE_HIDDEN + FILE_ATTRIBUTE_SYSTEM;
  if FindFirst(LPfad + '*', LFileAttribute, tmp1) = 0 then
  begin
    repeat  
      if (tmp1.Name <> '.') and (tmp1.Name <> '..') then  
      begin  
        LItem := ADirectoryListing.Add;  
        LItem.FileName := tmp1.Name;  
        LItem.Size := tmp1.Size;  
        LItem.OwnerName := 'Username';  
        LItem.GroupName := 'Groupname';  
        LItem.OwnerPermissions := 'rwx';  
        LItem.GroupPermissions := 'rwx';  
        LItem.UserPermissions := 'rwx';  
        if DirectoryExists(LPfad + tmp1.Name) then  
           LItem.ItemType := ditDirectory  
        else  
           LItem.ItemType := idftplist.ditFile;  
      end;  
    until FindNext(tmp1) <> 0;  
  end;  
  FindClose(tmp1);  
end; 

procedure TForm1.IdFTPServerChangeDirectory(ASender: TIdFTPServerThread;
  var VDirectory: String);
begin  
if not DirectoryExists('D:\' + VDirectory) then VDirectory := ASender.CurrentDir;
end; 

procedure TForm1.IdFTPServerMakeDirectory(ASender: TIdFTPServerThread;
  var VDirectory: String);
begin
CreateDirectory(PChar(VDirectory), nil);
end;

end.


Ich möchte einen FTP Server erstellen und mir fehlen noch viele Funktionen.
lösche,rename,execute,in unterverzeichnise springen und alles was ein ftp server bieten sollte. wer hilft mir beim fertig stellen, des tools?