Skip to content

Commit

Permalink
move func to proc_files unit
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey-T committed Oct 2, 2022
1 parent 3aa6e5b commit 1c29959
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
25 changes: 1 addition & 24 deletions app/formmain_commandline.inc
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,6 @@ begin
end;
end;

procedure _AppFindFilesByMask(List: TStringList; AMask: string);
var
Dir: string;
begin
Dir:= GetCurrentDirUTF8;

//support full dir path
if IsOsFullPath(AMask) then
begin
Dir:= ExtractFileDir(AMask);
AMask:= ExtractFileName(AMask);
end
else
//support relative dir path
if Pos(DirectorySeparator, AMask)>0 then
begin
Dir+= DirectorySeparator+ExtractFileDir(AMask);
AMask:= ExtractFileName(AMask);
end;

FindAllFiles(List, Dir, AMask, false{SubDirs});
end;

procedure TfmMain.DoLoadCommandParams(const AParams: array of string; AOpenOptions: string);
// Function handles passed file names, folder names, and such params as -r -nh -z -e,
// while others params are handled in InitAdditionalCommandLineOptions
Expand Down Expand Up @@ -253,7 +230,7 @@ begin
begin
List:= TStringList.Create;
try
_AppFindFilesByMask(List, SParam);
AppFindFilesByMask(List, SParam);
for SParam in List do
begin
Frame:= DoFileOpen(SParam, '', nil, AOpenOptions);
Expand Down
30 changes: 29 additions & 1 deletion app/proc_files.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

interface

uses
Classes;

function AppCreateFile(const fn: string): boolean;
function AppCreateFileJSON(const fn: string): boolean;

Expand All @@ -31,12 +34,13 @@ procedure AppBrowseToFilenameInShell(const fn: string);
function AppFileExtentionCreatable(const fn: string): boolean;
procedure AppFileCheckForNullBytes(const fn: string);
procedure AppMakeBackupFiles(const AFilename, AExtension: string; ACount: integer);
procedure AppFindFilesByMask(List: TStringList; AMask: string);


implementation

uses
Classes, SysUtils, LCLIntf,
SysUtils, LCLIntf,
FileUtil, LazFileUtils, LCLType,
ATStrings,
proc_globdata,
Expand Down Expand Up @@ -381,5 +385,29 @@ procedure AppMakeBackupFiles(const AFilename, AExtension: string; ACount: intege
end;
end;

procedure AppFindFilesByMask(List: TStringList; AMask: string);
var
Dir: string;
begin
Dir:= GetCurrentDirUTF8;

//support full dir path
if IsOsFullPath(AMask) then
begin
Dir:= ExtractFileDir(AMask);
AMask:= ExtractFileName(AMask);
end
else
//support relative dir path
if Pos(DirectorySeparator, AMask)>0 then
begin
Dir+= DirectorySeparator+ExtractFileDir(AMask);
AMask:= ExtractFileName(AMask);
end;

FindAllFiles(List, Dir, AMask, false{SubDirs});
end;


end.

0 comments on commit 1c29959

Please sign in to comment.