Contents | Prev | Next

7.4.23 The getfilemode procedure

Description

The getfilemode procedure retrieves the permission mode of a file. The permission mode can be AND'd with the permission constants to determine the permissions of the file.

Parameter

  1. The first parameter is an expression of string type or char type which is the name of the file whose permission mode is to be retrieved.
  2. The second parameter is a reference to a variable of integer type or word type which will store the permission mode of the file.

Example

   //*************************************************************
   //This program uses the built-in procedure "getfilemode" to
   // determine if a file is a directory.
   program isdirectory(input, output);
   var
      s : filename;
      mode : integer;
      isdir : boolean;
   begin
      write('Enter filename:');
      readln(s);
      s := fexpand(s);
      getfilemode(s, mode);
      isdir := (mode and dir_bit) <> 0;
      if isdir then
         writeln(s, ' is a directory')
      else
         writeln(s, ' is not a directory');
   end.

Portability

Operating Systems: All
Standard Pascal: No

Contents | Prev | Next