Manipulating File Attributes

A standard predicate enables getting and setting the (informational) attributes of files. Although documentation for DOS, OS/2 and MS Windows frequently talks about a "directory attribute", a file cannot be changed to a directory just by clearing this attribute.

(1) fileattrib/2

Depending on dataflow fileattrib will get or set the attributes for a file. In UNIX this corresponds to the file mode, meaning permissions, sticky bits, etc; see chmod(S).

    fileattrib(Name,Attrib)                         /* (i,o) (i,i) */

The Name must specify an existing file, otherwise fileattrib exits with an error. Note that the definition of getting or setting attributes is entirely operating system defined; in particular, you cannot set the file attributes for a directory. The attributes for the file appear in Attrib as an unsigned short. This may then be decomposed and/or changed using bitwise manipulation. For instance, the following will clear the system attribute for the DOS file "JNK":

The constant fa_notsys is the bitwise negation of fa_system. If you don't know how to find the negation, use the bitxor (see chapter 16) standard predicate: