System.SysUtils.TSearchRec
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 |
|---|---|---|
|
|
1 |
Read-only files |
|
|
2 |
Hidden files |
|
|
4 |
System files |
|
|
8 |
Volume ID files |
|
|
16 |
Directory files |
|
|
32 |
Archive files |
|
|
64 |
Symbolic link |
|
|
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
- System.SysUtils.FindNext
- System.SysUtils.FindClose
- System.TDateTime
- System.SysUtils.FileDateToDateTime
Code Examples