Show: Delphi C++
Display Preferences

System.SysUtils.TSearchRec

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

  TSearchRec = record
  private
    function GetTimeStamp: TDateTime;
  public
{$IFDEF MSWINDOWS}
    Time: Integer platform deprecated;
{$ENDIF MSWINDOWS}
{$IFDEF POSIX}
    Time: time_t platform;
{$ENDIF POSIX}
    Size: Int64;
    Attr: Integer;
    Name: TFileName;
    ExcludeAttr: Integer;
{$IFDEF MSWINDOWS}
    FindHandle: THandle platform;
    FindData: TWin32FindData platform;
{$ENDIF MSWINDOWS}
{$IFDEF POSIX}
    Mode: mode_t platform;
    FindHandle: Pointer platform;
    PathOnly: string platform;
    Pattern: string platform;
{$ENDIF POSIX}
    property TimeStamp: TDateTime read GetTimeStamp;
  end;

C++

struct DECLSPEC_DRECORD TSearchRec
{
private:
    System::TDateTime __fastcall GetTimeStamp();
public:
    int Time _DEPRECATED_ATTRIBUTE0 ;
    __int64 Size;
    int Attr;
    TFileName Name;
    int ExcludeAttr;
    NativeUInt FindHandle;
    _WIN32_FIND_DATAW FindData;
    __property System::TDateTime TimeStamp = {read=GetTimeStamp};
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

TSearchRec defines file information searched for by FindFirst or FindNext.

The TSearchRec type defines file information searched for by a FindFirst or FindNext function call. If a file is found, the fields of the TSearchRec type parameter are modified to specify the found file.

Attr represents the file attributes of the file. Test Attr against the following attribute constants or values to determine whether a file attribute matches the file's properties.

Note: Attribute constants map directly to DOS file attributes.
Constant Value Description

faReadOnly

1

Read-only files

faHidden

2

Hidden files

faSysFile

4

System files

faVolumeID

8

Volume ID files

faDirectory

16

Directory files

faArchive

32

Archive files

faSymLink

64

Symbolic link

faAnyFile

71

Any file

The faReadOnly constant has the same name as the enumerated value that is defined by the TFieldAttribute type. If both the System.SysUtils and Data.DB units are used in your source files, you must disambiguate by specifying the unit to qualify the use of faReadOnly. That is, write SysUtils.faReadOnly (Delphi) or SysUtils::faReadOnly (C++).

To test an attribute, combine the value of the Attr field with the attribute constant using the and operator. If the file has that attribute, the result will be greater than 0. For example, if the found file is a hidden file, the following expression will evaluate to True:

(SearchRec.Attr and faHidden) <> 0
(SearchRec.Attr & faHidden) != 0

Time contains the time stamp of the file. It can be converted to a TDateTime value using FileDateToDateTime.

Size contains the size of the file, in bytes.

Name contains the base file name, including extension.

FindHandle is an internal handle used to track a 'find' state.

FindData contains additional information such as the file creation time, last access time, and both the long and short file names.

See Also

Code Examples


Personal tools
In Other Languages
Previous Versions
Assistance