help files
Z505 | PasWiki | FUQ | Search | Main Docs | API Guide



[Overview][Constants][Types][Classes][Procedures and functions][Variables] Reference for unit 'sysutils' (#rtl)

FileGetAttr

Return attributes of a file.

Declaration

Source position: filutilh.inc line 92

function FileGetAttr(

  const FileName: String

):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. Not possible under unix.
faDirectory
File is a directory.
faArchive
file is an archive. 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 attribites of ',Name);
end;

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

Notes

 No notes exist for this page yet. 





lufdoc, Powtils, fpc, freepascal, delphi, kylix, c/c++, mysql, cgi web framework docs, Z505