Ignore:
Timestamp:
Jun 4, 2024, 12:22:49 AM (5 months ago)
Author:
chronos
Message:
  • Modified: Removed U prefix from unit names.
  • Modified: Updated Common package.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/FindFile.pas

    r74 r75  
    1919}
    2020
    21 unit UFindFile;
     21unit FindFile;
    2222
    2323interface
    2424
    2525uses
    26   SysUtils, Classes, Graphics, Controls, Forms, Dialogs, FileCtrl;
     26  SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
    2727
    2828type
     
    3535  private
    3636    s : TStringList;
    37 
    3837    fSubFolder : boolean;
    3938    fAttr: TFileAttrib;
    4039    fPath : string;
    4140    fFileMask : string;
    42 
    4341    procedure SetPath(Value: string);
    4442    procedure FileSearch(const inPath : string);
     
    4644    constructor Create(AOwner: TComponent); override;
    4745    destructor Destroy; override;
    48 
    4946    function SearchForFiles: TStringList;
    5047  published
     
    5552  end;
    5653
     54const
     55{$IFDEF WINDOWS}
     56  FilterAll = '*.*';
     57{$ENDIF}
     58{$IFDEF UNIX}
     59  FilterAll = '*';
     60{$ENDIF}
     61
    5762procedure Register;
     63
    5864
    5965implementation
     
    7177  inherited Create(AOwner);
    7278  Path := IncludeTrailingBackslash(UTF8Encode(GetCurrentDir));
    73   FileMask := '*.*';
     79  FileMask := FilterAll;
    7480  FileAttr := [ffaAnyFile];
    7581  s := TStringList.Create;
     
    7985begin
    8086  s.Free;
    81   inherited Destroy;
     87  inherited;
    8288end;
    8389
     
    109115  Attr := 0;
    110116  if ffaReadOnly in FileAttr then Attr := Attr + faReadOnly;
    111   if ffaHidden in FileAttr then Attr := Attr + faHidden;
    112   if ffaSysFile in FileAttr then Attr := Attr + faSysFile;
    113   if ffaVolumeID in FileAttr then Attr := Attr + faVolumeID;
     117  if ffaHidden in FileAttr then Attr := Attr + 2; //faHidden; use constant to avoid platform warning
     118  if ffaSysFile in FileAttr then Attr := Attr + 4; //faSysFile; use constant to avoid platform warning
     119  // Deprecated: if ffaVolumeID in FileAttr then Attr := Attr + faVolumeID;
    114120  if ffaDirectory in FileAttr then Attr := Attr + faDirectory;
    115121  if ffaArchive in FileAttr then Attr := Attr + faArchive;
    116122  if ffaAnyFile in FileAttr then Attr := Attr + faAnyFile;
    117123
    118   if SysUtils.FindFirst(UTF8Decode(inPath + FileMask), Attr, Rec) = 0 then
     124  if SysUtils.FindFirst(inPath + FileMask, Attr, Rec) = 0 then
    119125  try
    120126    repeat
    121       s.Add(inPath + UTF8Encode(Rec.Name));
     127      s.Add(inPath + Rec.Name);
    122128    until SysUtils.FindNext(Rec) <> 0;
    123129  finally
     
    127133  If not InSubFolders then Exit;
    128134
    129   if SysUtils.FindFirst(UTF8Decode(inPath + '*.*'), faDirectory, Rec) = 0 then
     135  if SysUtils.FindFirst(inPath + FilterAll, faDirectory, Rec) = 0 then
    130136  try
    131137    repeat
    132138      if ((Rec.Attr and faDirectory) > 0) and (Rec.Name <> '.')
    133139      and (Rec.Name <> '..') then
    134         FileSearch(IncludeTrailingBackslash(inPath + UTF8Encode(Rec.Name)));
     140        FileSearch(IncludeTrailingBackslash(inPath + Rec.Name));
    135141    until SysUtils.FindNext(Rec) <> 0;
    136142  finally
    137143    SysUtils.FindClose(Rec);
    138144  end;
    139 end; 
     145end;
    140146
    141147end.
    142 
Note: See TracChangeset for help on using the changeset viewer.