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