Mattias Gaertner wrote 80 lines
On Sat, 02 Aug 2003 10:04:24 -0400
Bob Wingard wrote:
>Vincent Snijders wrote:
>
>
>
>>Hi,
>>
>>Nice progress!
>>
>>I have a few remarks/questions:
>>- The second FindFirst (used to look for subdirectories) in
>>FindMatchingTextFiles needs a matching findclose.
>>
>>
>>
>Good eye, fixed.
>
>
I tried to apply and got:
patching file findinfilesdlg.pas
patching file ideprocs.pp
patch: **** malformed patch at line 71: Index: lcl/dirsel.pas
The patch seems to be ok. Does someone know, what this means?
Mattias
>>- In TLazFindInFilesDialog.DirectoryBrowseClick you use if then
>>to append the path delimeter. You can use PathDelim from SusUtils unit
>>or DirectorySeparator from the system unit (both part of fpc RTL). You
>>might look also to AppendPathDelim in the FileCtrl unit (part of the
>>LCL).
>>
>>
>>
>Again, you are correct. There is another decleration of AppendPathDelim
>off in the Codetools directory and that is the one that I originally
>saw. fixed.
>
>
>
>>- Why do you use
>>SysUtils.FindFirst(TempDir+FindMask,faAnyFile,FileInfo)
>>and not
>>SysUtils.FindFirst(TempDir+FindMask,faDirectory,FileInfo)
>>when you are looking for (sub)directories?
>>
>>
>>
>This works on Windows but will not return any files on Linux. I am not
>sure but I think it is because everything is a file under linux, so
>directories are files with the directory attribute set.
>
>
>
>>Regards,
>>Vincent Snijders.
>>
>>
>>
>>
><snip>
>Bob
>
>
>
Could have been somthing I did. Try this one.
Index: findinfilesdlg.pas
=================================================================== RCS file: /FPC/CVS/projects/lazarus/findinfilesdlg.pas,v retrieving revision 1.6
diff -u -r1.6 findinfilesdlg.pas
--- findinfilesdlg.pas 1 Aug 2003 09:44:51 -0000 1.6 +++ findinfilesdlg.pas 2 Aug 2003 16:35:44 -0000
@@ -62,6 +62,9 @@
implementation
+uses
+ filectrl;
+
{ TLazFindInFilesDialog }
constructor TLazFindInFilesDialog.Create(AOwner: TComponent);
@@ -340,10 +343,7 @@
begin
TheDirectory:= GetCurrentDir;
TheRootDir:= ExtractFileDrive(TheDirectory);
- if Length(TheRootDir)< 1 then
- TheRootDir:= '/' //Linux or Unix ?
- else
- TheRootDir:= TheRootDir + '\';
+ TheRootDir:= FileCtrl.AppendPathDelim(TheRootDir);
if SelectDirectory('Select A Directory', TheRootDir, TheDirectory, false) then
DirectoryComboBox.Text:= TheDirectory;
Index: ideprocs.pp
=================================================================== RCS file: /FPC/CVS/projects/lazarus/ideprocs.pp,v
retrieving revision 1.89
diff -u -r1.89 ideprocs.pp
--- ideprocs.pp 1 Aug 2003 09:44:51 -0000 1.89
+++ ideprocs.pp 2 Aug 2003 16:35:45 -0000
@@ -2100,19 +2100,23 @@
MaskList.Free;
end;//try-finally
//If selected then Look for and search subdirectories
- if (recursive) and (SysUtils.FindFirst(TempDir
- +FindMask,faAnyFile,FileInfo)=0) then
- begin
- if ((faDirectory and FileInfo.Attr)>0) then
+ try
+ if (recursive) and (SysUtils.FindFirst(TempDir
+ +FindMask,faAnyFile,FileInfo)=0) then
begin
- repeat
- // check if special file
- if (FileInfo.Name='.') or (FileInfo.Name='..') then continue;
- FindMatchingTextFiles
- (FileList,TempDir + FileInfo.Name,mask,recursive);
- until SysUtils.FindNext(FileInfo)0;
+ if ((faDirectory and FileInfo.Attr)>0) then
+ begin
+ repeat
+ // check if special file
+ if (FileInfo.Name='.') or (FileInfo.Name='..') then continue;
+ FindMatchingTextFiles
+ (FileList,TempDir + FileInfo.Name,mask,recursive);
+ until SysUtils.FindNext(FileInfo)0;
+ end;//if
end;//if
- end;//if
+ finally
+ SysUtils.FindClose(FileInfo);
+ end;//try-finally
end;//if
end;//FindMatchingFiles
Index: lcl/dirsel.pas
===================================================================
RCS file: /FPC/CVS/projects/lazarus/lcl/dirsel.pas,v
retrieving revision 1.2
diff -u -r1.2 dirsel.pas
--- lcl/dirsel.pas 2 Aug 2003 01:07:39 -0000 1.2
+++ lcl/dirsel.pas 2 Aug 2003 16:35:45 -0000
@@ -90,13 +90,12 @@
Result:= False;
if Dir '' then
begin
+ FCurrentDir:= Dir;
+ FileCtrl.AppendPathDelim(FCurrentDir);
i:= length(Dir);
- if Dir[i] = PathDelim then
- FCurrentDir:= Dir + FindMask
- else
- FCurrentDir:= Dir + PathDelim + FindMask;
+ FCurrentDir:= Dir + FindMask;
Try
- if SysUtils.FindFirst(FCurrentDir, faAnyFile,FileInfo)=0 then
+ if SysUtils.FindFirst(FCurrentDir, (faAnyFile),FileInfo)=0 then
begin
repeat
// check if special file
@@ -127,11 +126,10 @@
begin
if Dir '' then
begin
- i:= length(Dir);
- if Dir[i] = PathDelim then
- FCurrentDir:= Dir + FindMask
- else
- FCurrentDir:= Dir + PathDelim + FindMask;
+ FCurrentDir:= Dir;
+ FileCtrl.AppendPathDelim(FCurrentDir);
+ i:= length(FCurrentDir);
+ FCurrentDir:= Dir + FindMask;
Try
if SysUtils.FindFirst(FCurrentDir, faAnyFile,FileInfo)=0 then
begin