Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.343 Beiträge
Delphi 11 Alexandria
|
Re: Compare Files -> Optimieren
1. Jan 2009, 12:39
so mache ich das:
(vorab Größe vergleichen und dann blockweise erstes unterschiedliches Zeichen suchen)
Delphi-Quellcode:
procedure TDCustom.CompareFileNow;
const
BS = 1000;
type
TBB = array[1..BS] of Byte;
var
S1, S2: String;
F1, F2: File of Byte;
B1, B2: TBB;
F: Boolean;
R1, R2, I: Integer;
begin
...
S1 := FileName;
S2 := PathCompare + CompareFileName;
if (S1 <> '') and (S2 <> '') and (S1 <> S2) then
begin
if FileExists(S1) then
begin
...
if FileExists(S2) then
begin
F := True;
AssignFile(F1, S1);
Reset(F1);
AssignFile(F2, S2);
Reset(F2);
if FileSize(F1) = FileSize(F2) then
begin
repeat
BlockRead(F1, B1, Length(B1), R1);
BlockRead(F2, B2, Length(B2), R2);
if R1 = R2 then
begin
for I := 1 to R1 do
begin
if B1[I] <> B2[I] then
begin
F := False;
Break;
end;
end;
end
else
begin
F := False;
end;
until (not F) or (Eof(F1) and Eof(F2));
end
else
begin
F := False;
end;
CloseFile(F1);
CloseFile(F2);
FFileIsValue := F; // <---
end;
end;
end
else
...
end;
stahli
|
|
Zitat
|