Contents | Prev | Next

4.2.3 dir_bit

Description

dir_bit can be AND'd (see and operator (bitwise)) with the mode parameter returned by the built-in procedure getfilemode to determine if a file is a directory. NOTE: Directories are also called folders.

Example

The simple program below asks for a filename and then tests whether the 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