1.1 --- a/installer/UnitFunctions.pas Sun Nov 25 01:22:41 2007 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,126 +0,0 @@
1.4 -unit UnitFunctions;
1.5 -
1.6 -interface
1.7 -
1.8 -uses SysUtils, Classes, Windows, IdFTPList, Math;
1.9 -
1.10 -function CalcSpeed(eOld, eNew: Integer): String;
1.11 -// local
1.12 -function GetAllFiles(Mask: String; Attr: Integer; Recursive: Boolean; ShowDirs: Boolean; ShowPath: Boolean = True): TStringList;
1.13 -// ftp
1.14 -function GetAllDirs: TStringList;
1.15 -
1.16 -implementation
1.17 -
1.18 -uses UnitfrmMain;
1.19 -
1.20 -function CalcSpeed(eOld, eNew: Integer): String;
1.21 -begin
1.22 - Result := frmMain.Caption;
1.23 - if (eOld < eNew) and (eOld <> 0) then begin
1.24 - eOld := eNew - eOld;
1.25 - //eOld := eOld *2; // this is only used for faster updates...
1.26 - Result := 'Metamod:Source - Uploading with ' + FloatToStr(RoundTo(eOld / 1024, -2)) + ' kb/s';
1.27 - end;
1.28 -end;
1.29 -
1.30 -function GetAllFiles(Mask: String; Attr: Integer; Recursive: Boolean; ShowDirs: Boolean; ShowPath: Boolean = True): TStringList;
1.31 -var eSearch: TSearchRec;
1.32 -begin
1.33 - Result := TStringList.Create;
1.34 -
1.35 - // Find all files
1.36 - if FindFirst(Mask, Attr, eSearch) = 0 then
1.37 - begin
1.38 - repeat
1.39 - if eSearch.Name[1] <> '.' then begin
1.40 - if ShowPath then begin
1.41 - if ((eSearch.Attr and Attr) = eSearch.Attr) and ((eSearch.Attr and faDirectory) <> eSearch.Attr) then
1.42 - Result.Add(ExtractFilePath(Mask) + eSearch.Name)
1.43 - else if (ShowDirs) and ((eSearch.Attr and faDirectory) = eSearch.Attr) then
1.44 - Result.Add(ExtractFilePath(Mask) + eSearch.Name);
1.45 - end
1.46 - else begin
1.47 - if ((eSearch.Attr and Attr) = eSearch.Attr) and ((eSearch.Attr and faDirectory) <> eSearch.Attr) then
1.48 - Result.Add(eSearch.Name)
1.49 - else if (ShowDirs) and ((eSearch.Attr and faDirectory) = eSearch.Attr) then
1.50 - Result.Add(eSearch.Name);
1.51 - end;
1.52 -
1.53 - if ((eSearch.Attr and faDirectory) = eSearch.Attr) and (Recursive) then begin
1.54 - with GetAllFiles(ExtractFilePath(Mask) + eSearch.Name + '\' + ExtractFileName(Mask), Attr, True, ShowDirs, ShowPath) do begin
1.55 - Result.Text := Result.Text + Text;
1.56 - Free;
1.57 - end;
1.58 - end;
1.59 - end;
1.60 - until FindNext(eSearch) <> 0;
1.61 - end;
1.62 -end;
1.63 -
1.64 -function GetAllDirs: TStringList;
1.65 -var eList: TStringList;
1.66 - i: integer;
1.67 -begin
1.68 - eList := TStringList.Create;
1.69 - frmMain.IdFTP.List(eList);
1.70 - frmMain.IdFTP.DirectoryListing.LoadList(eList);
1.71 - eList.Clear;
1.72 - for i := 0 to frmMain.IdFTP.DirectoryListing.Count -1 do begin
1.73 - if frmMain.IdFTP.DirectoryListing.Items[i].ItemType = ditDirectory then
1.74 - eList.Add(frmMain.IdFTP.DirectoryListing.Items[i].FileName);
1.75 - end;
1.76 - Result := eList;
1.77 -end;
1.78 -
1.79 -{ This is another possibility I coded because I couldn't find another bug...
1.80 -
1.81 -function GetAllDirs: TStringList;
1.82 -var eList: TStringList;
1.83 - i, eStart: integer;
1.84 -begin
1.85 - eList := TStringList.Create;
1.86 - frmMain.IdFTP.List(eList, '', True);
1.87 - eStart := 0;
1.88 -
1.89 -
1.90 - // +----------------------------------------------------------------+
1.91 - // | drwxr-xr-x 5 web3 ftponly 2048 Jun 25 19:43 files |
1.92 - // | drwxr-xr-x 2 web3 ftponly 2048 Jun 25 19:57 html |
1.93 - // | drwxr-xr-x 3 root root 2048 Jun 20 05:03 log |
1.94 - // | drwxrwxrwx 2 web3 ftponly 2048 Jun 19 2004 phptmp |
1.95 - // +----------------------------------------------------------------+
1.96 -
1.97 -
1.98 - // at first remove all non-directories from the list
1.99 - for i := eList.Count -1 downto 0 do begin
1.100 - if Pos('d', eList[i]) <> 1 then
1.101 - eList.Delete(i);
1.102 - end;
1.103 - // then we have to find the position where ALL filenames start...
1.104 - for i := 0 to eList.Count -1 do begin
1.105 - if (eStart = 0) and (Pos(':', eList[i]) <> 0) then
1.106 - eStart := Pos(':', eList[i]);
1.107 - end;
1.108 -
1.109 - if eStart = 0 then
1.110 - eList.Clear
1.111 - else begin
1.112 - // find the position
1.113 - for i := 0 to eList.Count -1 do begin
1.114 - if Pos(':', eList[i]) <> 0 then begin
1.115 - while (eStart <> Length(eList[i])) and (eList[i][eStart] <> #32) do
1.116 - Inc(eStart, 1);
1.117 - end;
1.118 - end;
1.119 - // remove the detail stuff...
1.120 - for i := 0 to eList.Count -1 do
1.121 - eList[i] := Copy(eList[i], eStart +1, Length(eList[i]));
1.122 - end;
1.123 -
1.124 - Result := eList;
1.125 -end; }
1.126 -
1.127 -end.
1.128 -
1.129 -