When testing for a single specific attribute, you need to use bitwise arithmetic. For example,consider the following faulty code:



This test succeeds only if the read-only attribute is the only attribute for the current file. This israrely the case. If you want to successfully check whether the file is read-only, you need this codeinstead:



When setting an attribute, you must also use bitwise arithmetic. In this case, you need to ensure
that you don’t inadvertently wipe out the other attributes that are already set.




