Changeset 520 for Common/UCommon.pas


Ignore:
Timestamp:
Mar 7, 2019, 4:34:53 PM (6 years ago)
Author:
chronos
Message:
  • Modified: Removed dependency on TemplateGenerics and used fgl unit as replacement.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/UCommon.pas

    r518 r520  
    2828    unfDNSDomainName = 11);
    2929
    30   TFilterMethodMethod = function (FileName: string): Boolean of object;
     30  TFilterMethod = function (FileName: string): Boolean of object;
     31  TFileNameMethod = procedure (FileName: string) of object;
     32
    3133var
    3234  ExceptionHandler: TExceptionEvent;
     
    7476procedure SaveStringToFile(S, FileName: string);
    7577procedure SearchFiles(AList: TStrings; Dir: string;
    76   FilterMethod: TFilterMethodMethod = nil);
     78  FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil);
    7779function GetStringPart(var Text: string; Separator: string): string;
    7880function StripTags(const S: string): string;
     
    8183function PosFromIndexReverse(SubStr: string; Text: string;
    8284  StartIndex: Integer): Integer;
     85procedure CopyStringArray(Dest: TStringArray; Source: array of string);
    8386
    8487
     
    108111  I: Integer;
    109112begin
     113  Result := '';
    110114  for I := 1 to Length(Source) do begin
    111115    Result := Result + LowerCase(IntToHex(Ord(Source[I]), 2));
     
    543547
    544548procedure SearchFiles(AList: TStrings; Dir: string;
    545   FilterMethod: TFilterMethodMethod = nil);
     549  FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil);
    546550var
    547551  SR: TSearchRec;
     
    553557        if (SR.Name = '.') or (SR.Name = '..') or (Assigned(FilterMethod) and (not FilterMethod(SR.Name) or
    554558          not FilterMethod(Copy(Dir, 3, Length(Dir)) + SR.Name))) then Continue;
     559        if Assigned(FileNameMethod) then
     560          FileNameMethod(Dir + SR.Name);
    555561        AList.Add(Dir + SR.Name);
    556562        if (SR.Attr and faDirectory) <> 0 then
     
    654660end;
    655661
     662procedure CopyStringArray(Dest: TStringArray; Source: array of string);
     663var
     664  I: Integer;
     665begin
     666  SetLength(Dest, Length(Source));
     667  for I := 0 to Length(Dest) - 1 do
     668    Dest[I] := Source[I];
     669end;
     670
    656671
    657672initialization
Note: See TracChangeset for help on using the changeset viewer.