Subversion Repositories delphiutils

Rev

Rev 84 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 84 Rev 85
Line 14... Line 14...
14
    Label1: TLabel;
14
    Label1: TLabel;
15
    Label2: TLabel;
15
    Label2: TLabel;
16
    ProgressBar1: TProgressBar;
16
    ProgressBar1: TProgressBar;
17
    procedure Button1Click(Sender: TObject);
17
    procedure Button1Click(Sender: TObject);
18
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
18
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
-
 
19
    procedure FormCreate(Sender: TObject);
19
  private
20
  private
20
    procedure FindFiles(FilesList: TStrings; StartDir, FileMask: string; errorSL: TStrings=nil);
21
    procedure FindFiles(FilesList: TStrings; StartDir, FileMask: string; errorSL: TStrings=nil);
21
    procedure EnableDisableControls(enabled: boolean);
22
    procedure EnableDisableControls(enabled: boolean);
22
    function Readable(filename: string): boolean;
23
    function Readable(filename: string): boolean;
23
  end;
24
  end;
Line 43... Line 44...
43
  IsFound := FindFirst(StartDir+FileMask, faAnyFile-faDirectory, SR) = 0;
44
  IsFound := FindFirst(StartDir+FileMask, faAnyFile-faDirectory, SR) = 0;
44
  while IsFound do
45
  while IsFound do
45
  begin
46
  begin
46
    Application.ProcessMessages;
47
    Application.ProcessMessages;
47
    if Application.Terminated then Abort;
48
    if Application.Terminated then Abort;
-
 
49
 
-
 
50
    if FilesList.Count = FilesList.Capacity - 1 then
-
 
51
      FilesList.Capacity := FilesList.Capacity + 1000;
-
 
52
 
48
    FilesList.Add(StartDir + SR.Name);
53
    FilesList.Add(StartDir + SR.Name);
49
    IsFound := FindNext(SR) = 0;
54
    IsFound := FindNext(SR) = 0;
50
  end;
55
  end;
51
  FindClose(SR);
56
  FindClose(SR);
52
 
57
 
Line 115... Line 120...
115
  try
120
  try
116
    Memo1.Lines.Clear;
121
    Memo1.Lines.Clear;
117
    cnt := 0;
122
    cnt := 0;
118
    sl := TStringList.Create;
123
    sl := TStringList.Create;
119
    try
124
    try
-
 
125
      sl.Sorted := false;
120
      sl.BeginUpdate;
126
      sl.BeginUpdate;
121
      Label2.Caption := 'Scan folders ...';
127
      Label2.Caption := 'Scan folders ...';
122
     
128
     
123
      FindFiles(sl, edit1.text, '*', Memo1.Lines);
129
      FindFiles(sl, edit1.text, '*', Memo1.Lines);
124
      Inc(cnt, Memo1.Lines.Count); // failed folders
130
      Inc(cnt, Memo1.Lines.Count); // failed folders
Line 135... Line 141...
135
        begin
141
        begin
136
          Memo1.Lines.Add(fil);
142
          Memo1.Lines.Add(fil);
137
          inc(cnt);
143
          inc(cnt);
138
        end;
144
        end;
139
 
145
 
-
 
146
        QueryPerformanceCounter(c2);
-
 
147
        elapsedSecs := Ceil((c2-c1)/f);
140
        Label2.Caption := MinimizeName(fil, Label2.Canvas, Label2.Width);
148
        Label2.Caption := MinimizeName(Format('[%.2d:%.2d:%.2d] %s', [elapsedSecs div 3600, elapsedSecs mod 3600 div 60, elapsedSecs mod 3600 mod 60, fil]), Label2.Canvas, Label2.Width);
141
 
149
 
142
        Application.ProcessMessages;
150
        Application.ProcessMessages;
143
        if Application.Terminated then Abort;
151
        if Application.Terminated then Abort;
144
      end;
152
      end;
145
      sl.EndUpdate;
153
      sl.EndUpdate;
Line 150... Line 158...
150
    if not Application.Terminated then
158
    if not Application.Terminated then
151
    begin
159
    begin
152
      QueryPerformanceCounter(c2);
160
      QueryPerformanceCounter(c2);
153
      elapsedSecs := Ceil((c2-c1)/f);
161
      elapsedSecs := Ceil((c2-c1)/f);
154
 
162
 
155
      ShowMessageFmt('Finished. Found %d error(s). Time: %.2d:%.2d:%.2d', [cnt, elapsedSecs div 3600, elapsedSecs mod 3600 div 60, elapsedSecs mod 3600 mod 60]);
163
      ShowMessageFmt('Finished. Found %d error(s). Elapsed time: %.2d:%.2d:%.2d', [cnt, elapsedSecs div 3600, elapsedSecs mod 3600 div 60, elapsedSecs mod 3600 mod 60]);
156
    end;
164
    end;
157
  finally
165
  finally
158
    EnableDisableControls(true);
166
    EnableDisableControls(true);
159
  end;
167
  end;
160
end;
168
end;
Line 162... Line 170...
162
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
170
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
163
begin
171
begin
164
  Application.Terminate;
172
  Application.Terminate;
165
end;
173
end;
166
 
174
 
-
 
175
procedure TForm1.FormCreate(Sender: TObject);
-
 
176
begin
-
 
177
  DoubleBuffered := true;
-
 
178
 
-
 
179
  {$IFDEF UNICODE}
-
 
180
  Caption := Caption + ' [Unicode]';
-
 
181
  {$ELSE}
-
 
182
  Caption := Caption + ' [ANSI]';
-
 
183
  {$ENDIF}
-
 
184
end;
-
 
185
 
167
procedure TForm1.EnableDisableControls(enabled: boolean);
186
procedure TForm1.EnableDisableControls(enabled: boolean);
168
begin
187
begin
169
  Button1.Enabled := enabled;
188
  Button1.Enabled := enabled;
170
  Label1.Enabled := enabled;
189
  Label1.Enabled := enabled;
171
  Edit1.Enabled := enabled;
190
  Edit1.Enabled := enabled;
172
  Memo1.Enabled := enabled;
191
  // Memo1.Enabled := enabled; // is already readonly by default
173
end;
192
end;
174
 
193
 
175
end.
194
end.