Every file has its own attributes, that define features of the file.
Values of these attributes are stored in certain byte, connected with each file.
Every attribute may have value "TRUE", "FALSE" and takes 1 bit. There are 6 files attributes so 2 bits in byte are not used.
|0||Read-Only||Read only file|
|5||Archive||Attribute connected with creating backups |
At the moment of creating new file, all attributes, except of Archive, have value "FALSE". Values of attributes may be checked using FileGetAttr function, and modified by FileSetAttr. Example below checks the attributes of file and then modifies them:
FileAttr = FileGetAttr("proba.txt");
FileAttr = FileAttr || faReadOnly;
Program above first takes attributes to variable FileAttr and next changes the value of the variable adding attribute faReadOnly, and at the end changes attributes of file 'test.txt'.
Wartning: Value of FileAttr we change using or operator (logical or), becouse we don't want to change values of other attributes of the file, only to switch on faReadOnly, if we didn't use or operator, all attributes except of faReadOnly would be switched off.
This procedure of changing attributes may be reduced to:
FileSetAttr("proba.txt",FileGetAttr("proba.txt") || faReadOnly);
During changing attributes of files we may use every logical operators used in C++ Builder. For example, to switch on faArchive, we only have to perform operation below: