Unit 'sysutils' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

FileGetAttr

Return attributes of a file.

Declaration

Source position: filutilh.inc line 229

function FileGetAttr(

  const FileName: UnicodeString

):LongInt;

function FileGetAttr(

  const FileName: RawByteString

):LongInt;

Description

FileGetAttr returns the attribute settings of file FileName. The attribute is a OR-ed combination of the following constants:

faReadOnly
The file is read-only.
faHidden
The file is hidden. (On UNIX, this means that the filename starts with a dot)
faSysFile
The file is a system file (On UNIX, this means that the file is a character, block or FIFO file).
faVolumeId
Volume Label. Only for DOS/Windows on a plain FAT (not VFAT or Fat32) file system.
faDirectory
File is a directory.
faArchive
file should be archived. Not possible on Unix

Errors

In case of error, -1 is returned.

See also

FileSetAttr

  

Set the attributes of a file.

FileAge

  

Return the timestamp of a file.

FileGetDate

  

Return the file time of an opened file.

Example

Program Example40;

{ This program demonstrates the FileGetAttr function }

Uses sysutils;

Procedure Testit (Name : String);

Var F : Longint;

Begin
  F:=FileGetAttr(Name);
  If F<>-1 then
    begin
    Writeln ('Testing : ',Name);
    If (F and faReadOnly)<>0 then
      Writeln ('File is ReadOnly');
    If (F and faHidden)<>0 then
      Writeln ('File is hidden');
    If (F and faSysFile)<>0 then
      Writeln ('File is a system file');
    If (F and faVolumeID)<>0 then
      Writeln ('File is a disk label');
    If (F and faArchive)<>0 then
      Writeln ('File is artchive file');
    If (F and faDirectory)<>0 then
      Writeln ('File is a directory');
    end
  else
   Writeln ('Error reading attributes of ',Name);
end;

begin
  testit ('ex40.pp');
  testit (ParamStr(0));
  testit ('.');
  testit ('/');
End.

Documentation generated on: Oct 02 2024