-
Notifications
You must be signed in to change notification settings - Fork 1
/
Search.Dpr
97 lines (88 loc) · 2.92 KB
/
Search.Dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
(**
This module defines the Search Win32 console application. This application is designed to provide
general file search and regular expression search capabilities for files on disk.
@version 1.2
@Author David Hoyle
@Date 03 Jun 2018
@todo Add switch for RegEx filename matching
@todo Check that GREP will work with multi-line matches
**)
Program Search;
{$APPTYPE CONSOLE}
{$R *.RES}
{$R 'SearchVersionInfo.res' 'SearchVersionInfo.RC'}
uses
{$IFDEF EurekaLog}
EMemLeaks,
EResLeaks,
ESendMailMAPI,
ESendMailSMAPI,
EDialogConsole,
EDebugExports,
EDebugJCL,
EMapWin32,
EAppConsole,
ExceptionLog7,
{$ENDIF EurekaLog}
System.SysUtils,
System.RegularExpressionsCore,
Search.FilesCls in 'Source\Search.FilesCls.pas',
Search.Functions in 'Source\Search.Functions.pas',
Search.Engine in 'Source\Search.Engine.pas',
Search.Types in 'Source\Search.Types.pas',
Search.RegExMatches in 'Source\Search.RegExMatches.pas',
Search.FileCls in 'Source\Search.FileCls.pas',
Search.Interfaces in 'Source\Search.Interfaces.pas',
Search.Constants in 'Source\Search.Constants.pas',
Search.StrUtils in 'Source\Search.StrUtils.pas',
Search.ConvertDate in 'Source\Search.ConvertDate.pas',
Search.ResourceStrings in 'Source\Search.ResourceStrings.pas',
Search.Help in 'Source\Search.Help.pas',
Search.Console in 'Source\Search.Console.pas',
Search.DisplayCriteria in 'Source\Search.DisplayCriteria.pas',
Search.Options in 'Source\Search.Options.pas';
ResourceString
(** A resource string to define the Exception output format. **)
strException = #13#10'Exception raised:'#13#10' %s';
(** A resource string for formatting information. **)
strPressEnterToFinish = 'Debug Mode: Press <Enter> to finish.';
Var
(** A variable to hold whether an exception has occurred. **)
boolException: Boolean;
(** An interface reference for calling the search engine. **)
SearchEngine : ISearchEngine;
Begin
{$IFDEF EUREKALOG}
SetEurekaLogState(DebugHook = 0);
{$ENDIF}
ReportMemoryLeaksOnShutdown := DebugHook <> 0;
boolException := False;
SearchEngine := TSearch.Create;
Try
SearchEngine.Run;
Except
On E: EAbort Do
Begin
SearchEngine.Console.OutputToConsoleLn(coStd, strSearchAborted);
boolException := False;
End;
On E: ESearchException Do
Begin
SearchEngine.Console.OutputToConsoleLn(coErr, Format(strException, [E.Message]), scException);
boolException := True;
End;
On E : ERegularExpressionError Do
Begin
SearchEngine.Console.OutputToConsoleLn(coErr, Format(strException, [E.Message]), scException);
boolException := True;
End;
End;
If (clsDebug In CommandLineSwitches) Or (DebugHook <> 0) Then
Begin
SearchEngine.Console.OutputToConsoleLn(coStd);
SearchEngine.Console.OutputToConsole(coStd, strPressEnterToFinish);
Readln;
End;
If boolException Then
Halt(1);
End.