IDE: clean directory: fixed checking reguar expression, bug #20382

git-svn-id: trunk@32574 -
This commit is contained in:
mattias 2011-09-30 18:48:38 +00:00
parent 8dc1234b17
commit 173b64a12c
4 changed files with 22 additions and 15 deletions

View File

@ -155,12 +155,9 @@ object CleanDirectoryDialog: TCleanDirectoryDialog
OKButton.Name = 'OKButton'
OKButton.Caption = '&ОК'
HelpButton.Name = 'HelpButton'
HelpButton.Caption = '&Справка'
CloseButton.Name = 'CloseButton'
CloseButton.Caption = '&Закрыть'
CloseButton.Enabled = False
CancelButton.Name = 'CancelButton'
CancelButton.Caption = 'Отмена'
TabOrder = 3
ShowButtons = [pbOK, pbCancel, pbHelp]
ShowBevel = False

View File

@ -100,6 +100,7 @@ procedure TCleanDirectoryDialog.OkButtonClick(Sender: TObject);
var
List: TStrings;
begin
ModalResult:=mrNone;
SaveSettings;
if not SearchFilesToDelete(List) then exit;
try
@ -325,6 +326,7 @@ var
const FilterAsText: string): boolean;
var
Expr: String;
s: String;
begin
Result:=false;
if FilterAsText='' then begin
@ -339,12 +341,16 @@ var
Expr:=FilterAsText;
try
Filter.Expression:=Expr;
// do a simple test
Filter.Exec('test.file');
Result:=true;
except
on E: Exception do begin
MessageDlg('Invalid Mask',
'The mask "'+FilterAsText+'" is not a valid expression.',
mtError,[mbCancel],0);
if SimpleSyntax then
s:=Format(lisTheFileMaskIsInvalid, [FilterAsText])
else
s:=Format(lisTheFileMaskIsNotAValidRegularExpression, [FilterAsText]);
MessageDlg(lisInvalidMask, s, mtError, [mbCancel], 0);
end;
end;
end;
@ -364,10 +370,10 @@ begin
Directory:=AppendPathDelim(Directory);
// setup filters
SetupFilter(RemoveFilterRegExpr,SimpleSyntaxRemoveCheckbox.Checked,
RemoveCombobox.Text);
SetupFilter(KeepFilterRegExpr,SimpleSyntaxKeepCheckbox.Checked,
KeepCombobox.Text);
if not SetupFilter(RemoveFilterRegExpr,SimpleSyntaxRemoveCheckbox.Checked,
RemoveCombobox.Text) then exit;
if not SetupFilter(KeepFilterRegExpr,SimpleSyntaxKeepCheckbox.Checked,
KeepCombobox.Text) then exit;
// search files
List:=TStringList.Create;

View File

@ -2515,12 +2515,12 @@ end;
{------------------------------------------------------------------------------
function SimpleSyntaxToRegExpr(const Src: string): string;
. -> \.
* -> .*
? -> .
, -> |
; -> |
Backslash characters .+
Finally enclose by ^( )$
------------------------------------------------------------------------------}
function SimpleSyntaxToRegExpr(const Src: string): string;
@ -2538,7 +2538,7 @@ begin
c:=Src[SrcPos];
case c of
'\': inc(SrcPos);
'*','.':
'*','.','+':
inc(DestLen);
end;
inc(SrcPos);
@ -2559,11 +2559,11 @@ begin
Result[DestPos]:=Src[SrcPos];
inc(DestPos);
end;
'.':
'.','+':
begin
Result[DestPos]:='\';
inc(DestPos);
Result[DestPos]:='.';
Result[DestPos]:=c;
inc(DestPos);
end;
'*':

View File

@ -3316,6 +3316,10 @@ resourcestring
lisUnableToReadFile = 'Unable to read file';
lisUnableToReadFilename = 'Unable to read file %s%s%s.';
lisErrorDeletingFile = 'Error deleting file';
lisInvalidMask = 'Invalid Mask';
lisTheFileMaskIsNotAValidRegularExpression = 'The file mask "%s" is not a '
+'valid regular expression.';
lisTheFileMaskIsInvalid = 'The file mask "%s" is invalid.';
lisUnableToDeleteAmbiguousFile = 'Unable to delete ambiguous file %s%s%s';
lisErrorRenamingFile = 'Error renaming file';
lisUnableToRenameAmbiguousFileTo = 'Unable to rename ambiguous file %s%s%s%'