The getfilemode procedure


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.


  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.


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


Operating Systems: All
Standard Pascal: No