1 |
torben |
2671 |
// ***** BEGIN LICENSE BLOCK *****
|
2 |
|
|
// * Version: MPL 1.1
|
3 |
|
|
// *
|
4 |
|
|
// * The contents of this file are subject to the Mozilla Public License Version
|
5 |
|
|
// * 1.1 (the "License"); you may not use this file except in compliance with
|
6 |
|
|
// * the License. You may obtain a copy of the License at
|
7 |
|
|
// * http://www.mozilla.org/MPL/
|
8 |
|
|
// *
|
9 |
|
|
// * Software distributed under the License is distributed on an "AS IS" basis,
|
10 |
|
|
// * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
11 |
|
|
// * for the specific language governing rights and limitations under the
|
12 |
|
|
// * License.
|
13 |
|
|
// *
|
14 |
|
|
// * The Original Code is TurboPower SysTools
|
15 |
|
|
// *
|
16 |
|
|
// * The Initial Developer of the Original Code is
|
17 |
|
|
// * TurboPower Software
|
18 |
|
|
// *
|
19 |
|
|
// * Portions created by the Initial Developer are Copyright (C) 1996-2002
|
20 |
|
|
// * the Initial Developer. All Rights Reserved.
|
21 |
|
|
// *
|
22 |
|
|
// * Contributor(s):
|
23 |
|
|
// *
|
24 |
|
|
// * ***** END LICENSE BLOCK *****
|
25 |
|
|
//---------------------------------------------------------------------------
|
26 |
|
|
#include <vcl.h>
|
27 |
|
|
#pragma hdrstop
|
28 |
|
|
|
29 |
|
|
#include "exenumfu.h"
|
30 |
|
|
//---------------------------------------------------------------------------
|
31 |
|
|
#pragma package(smart_init)
|
32 |
|
|
#pragma resource "*.dfm"
|
33 |
|
|
TForm1 *Form1;
|
34 |
|
|
//---------------------------------------------------------------------------
|
35 |
|
|
__fastcall TForm1::TForm1(TComponent* Owner)
|
36 |
|
|
: TForm(Owner)
|
37 |
|
|
{
|
38 |
|
|
}
|
39 |
|
|
//---------------------------------------------------------------------------
|
40 |
|
|
bool __fastcall ProcessAll(const Sysutils::TSearchRec &SR, bool ForInclusion,
|
41 |
|
|
bool &Abort)
|
42 |
|
|
{
|
43 |
|
|
Abort = false;
|
44 |
|
|
if (StopIt) {
|
45 |
|
|
Abort = true;
|
46 |
|
|
return false;
|
47 |
|
|
}
|
48 |
|
|
else {
|
49 |
|
|
Application->ProcessMessages();
|
50 |
|
|
return true;
|
51 |
|
|
}
|
52 |
|
|
}
|
53 |
|
|
//---------------------------------------------------------------------------
|
54 |
|
|
bool __fastcall TextFilesOnly(const Sysutils::TSearchRec &SR, bool ForInclusion,
|
55 |
|
|
bool &Abort)
|
56 |
|
|
{
|
57 |
|
|
bool Rslt;
|
58 |
|
|
Abort = false;
|
59 |
|
|
if (StopIt) {
|
60 |
|
|
Abort = true;
|
61 |
|
|
return false;
|
62 |
|
|
}
|
63 |
|
|
else {
|
64 |
|
|
Application->ProcessMessages();
|
65 |
|
|
|
66 |
|
|
if (ForInclusion) {
|
67 |
|
|
Rslt = false;
|
68 |
|
|
String S = SR.Name;
|
69 |
|
|
if ((UpperCase(ExtractFileExt(S)) == ".TXT") ||
|
70 |
|
|
((SR.Attr && faDirectory) > 0)) {
|
71 |
|
|
Rslt = true;
|
72 |
|
|
}
|
73 |
|
|
return Rslt;
|
74 |
|
|
}
|
75 |
|
|
else {
|
76 |
|
|
return true;
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
}
|
80 |
|
|
//---------------------------------------------------------------------------
|
81 |
|
|
void __fastcall TForm1::Button2Click(TObject *Sender)
|
82 |
|
|
{
|
83 |
|
|
StopIt = true;
|
84 |
|
|
}
|
85 |
|
|
//---------------------------------------------------------------------------
|
86 |
|
|
|
87 |
|
|
void __fastcall TForm1::FormCreate(TObject *Sender)
|
88 |
|
|
{
|
89 |
|
|
AList = new TStringList;
|
90 |
|
|
Edit1->Text = "C:\\";
|
91 |
|
|
}
|
92 |
|
|
//---------------------------------------------------------------------------
|
93 |
|
|
|
94 |
|
|
void __fastcall TForm1::FormDestroy(TObject *Sender)
|
95 |
|
|
{
|
96 |
|
|
delete AList;
|
97 |
|
|
}
|
98 |
|
|
//---------------------------------------------------------------------------
|
99 |
|
|
|
100 |
|
|
void __fastcall TForm1::Button1Click(TObject *Sender)
|
101 |
|
|
{
|
102 |
|
|
AList->Clear();
|
103 |
|
|
ListBox1->Clear();
|
104 |
|
|
|
105 |
|
|
Screen->Cursor = crHourGlass;
|
106 |
|
|
StopIt = false;
|
107 |
|
|
|
108 |
|
|
if (!CheckBox2->Checked) {
|
109 |
|
|
EnumerateFiles(Edit1->Text, AList, CheckBox1->Checked, ProcessAll);
|
110 |
|
|
ListBox1->Items = AList;
|
111 |
|
|
} else {
|
112 |
|
|
EnumerateFiles(Edit1->Text, AList, CheckBox1->Checked, TextFilesOnly);
|
113 |
|
|
/*by its nature, EnumerateFiles also returns directory names*/
|
114 |
|
|
/*remove those from the list - leaving only the text files*/
|
115 |
|
|
for (long int I = 0; I < AList->Count; I++) {
|
116 |
|
|
if (UpperCase(ExtractFileExt(AList->Strings[I])) == ".TXT") {
|
117 |
|
|
ListBox1->Items->Add(AList->Strings[I]);
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
Screen->Cursor = crDefault;
|
123 |
|
|
ListBox1->Update();
|
124 |
|
|
|
125 |
|
|
}
|
126 |
|
|
//---------------------------------------------------------------------------
|
127 |
|
|
|