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.
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.
Operating Systems: All
Standard Pascal: No