Unit 'BaseUnix' Package
[Overview][Constants][Types][Procedures and functions][Index] [#rtl]

FPFStat

Retrieve file information about a file descriptor.

Declaration

Source position: bunxh.inc line 85

function FpFStat(

  fd: cint;

  var sb: Stat

):cint;

function FPFStat(

  var F: Text;

  var Info: Stat

):Boolean;

function FPFStat(

  var F: file;

  var Info: Stat

):Boolean;

Description

FpFStat gets information about the file specified in one of the following:

Fd
a valid file descriptor.
F
an opened text file or untyped file.

and stores it in Info, which is of type stat. The function returns zero if the call was successful, a nonzero return value indicates failure.

Errors

Extended error information can be retrieved using fpGetErrno.

sys_enoent
Path does not exist.

See also

FpStat

  

Retrieve file information about a file descriptor.

FpLStat

  

Return information about symbolic link. Do not follow the link.

Example

program example28;

{ Program to demonstrate the FStat function. }

uses BaseUnix;

var f : text;
    i : byte;
    info : stat;

begin
  { Make a file }
  assign (f,'test.fil');
  rewrite (f);
  or:=1 to 10 do writeln (f,'Testline # ',i);
  close (f);
  { Do the call on made file. }
  if fpstat ('test.fil',info)<>0 then
     begin
       writeln('Fstat failed. Errno : ',fpgeterrno);
       halt (1);
     end;
  writeln;
  writeln ('Result of fstat on file ''test.fil''.');
  writeln ('Inode   : ',info.st_ino);
  writeln ('Mode    : ',info.st_mode);
  writeln ('nlink   : ',info.st_nlink);
  writeln ('uid     : ',info.st_uid);
  writeln ('gid     : ',info.st_gid);
  writeln ('rdev    : ',info.st_rdev);
  writeln ('Size    : ',info.st_size);
  writeln ('Blksize : ',info.st_blksize);
  writeln ('Blocks  : ',info.st_blocks);
  writeln ('atime   : ',info.st_atime);
  writeln ('mtime   : ',info.st_mtime);
  writeln ('ctime   : ',info.st_ctime);
  { Remove file }
  erase (f);
end.

Documentation generated on: Dec 25 2024