Einzelnen Beitrag anzeigen

Benutzerbild von cherry
cherry

Registriert seit: 14. Nov 2005
561 Beiträge
 
RAD-Studio 2009 Ent
 
#4

Re: Ordner downloaden & syncronisieren

  Alt 9. Okt 2007, 06:29
Ok dann hilft dir dies eventuell weiter. Ich hab mal diese DLL erstellt um Dateistrukturen in eine DB zu schreiben.
Das Problem ist ja hauptsächlich das dies rekursiv sein muss. Hier also die DLL die dir sicherlich weiter hilft.

Delphi-Quellcode:
library analyse;

{ enemyleft[at]gmail.com - 13.08.2007 }

uses
  SysUtils,
  Classes;

{$R *.res}

procedure GetTreeList(Directory: String; const Mask: String;
                              dList, fList, sList, tList, doList, dosList,
                              aList: TStrings;
                              WithSubDirs, ClearList: Boolean) stdcall;
var
  DirSize: Integer;
procedure ScanDir(const Directory: String);
var
  SR: TSearchRec;
begin

  if FindFirst(Directory + Mask, faAnyFile and not faDirectory, SR) = 0 then
  begin
    try
      repeat
        dList.Add(Directory);
        fList.Add(SR.Name);
        sList.Add(IntToStr(SR.Size));
        tList.Add(IntToStr(SR.Time));
        aList.Add(IntToStr(SR.Attr));
        DirSize := DirSize + SR.Size;
      until FindNext(SR) <> 0;
    finally
      doList.Add(Directory);
      dosList.Add(IntToStr(DirSize));
      DirSize := 0;
      FindClose(SR);
    end;
  end;

  if WithSubDirs then begin
    if FindFirst(Directory + '*.*', faAnyFile, SR) = 0 then try
      repeat
        if ((SR.attr and faDirectory) = faDirectory) and
           (SR.Name <> '.') and (SR.Name <> '..') then
          ScanDir(Directory + SR.Name + '\');
      until FindNext(SR) <> 0;
    finally
      FindClose(SR);
    end;
  end;
end;

begin
  DirSize := 0;
  dList.BeginUpdate;
  fList.BeginUpdate;
  sList.BeginUpdate;
  tList.BeginUpdate;
  doList.BeginUpdate;
  dosList.BeginUpdate;
  aList.BeginUpdate;
  try
    if ClearList then
    begin
      dList.Clear;
      fList.Clear;
      sList.Clear;
      tList.Clear;
      doList.Clear;
      dosList.Clear;
      aList.Clear;
    end;
    if Directory = 'then Exit;
    if Directory[Length(Directory)] <> '\then
      Directory := Directory + '\';
    ScanDir(Directory);
  finally
    dList.EndUpdate;
    fList.EndUpdate;
    sList.EndUpdate;
    tList.EndUpdate;
    doList.EndUpdate;
    dosList.EndUpdate;
    aList.EndUpdate;
  end;
end;

exports
  GetTreeList;

begin

end.
Ist das nur mein Gefühl, oder ist die ganze Welt verrückt geworden!?
  Mit Zitat antworten Zitat