Shell Commands/Protect

From MorphOS Library

< Shell Commands

Protect - Changes the protection flags of a file

FILE/A, FLAGS, ADD/S, SUB/S, ALL/S, QUIET/S

FILE  - Medatory: name/pattern of the files                                    
FLAGS - Flags to modify (see below)
ADD   - Add the specified flags
SUB   - Remove the specified flags
ALL   - Modify flags of all files matching entered pattern
QUIET - Removes text messages

The protection bits are represented by letters:

s - The file is a script
p - The file is a pure command and can be made resident
a - The file has been archived
r - The file can be read
w - The file can be written to (altered)
e - The file is executable (a program)
d - The file or directory can be deleted.
    (Files within a delete-protected directory can still be deleted.)

You have three ways to set or clear protection flags of a file:

  1. Specify the protection bits you want to set using the FLAGS argument without any other argument.
  2. Use ADD and/or SUB followed by the bits you want to set/clear
  3. Use '+' followed by the bits you want to set and '-' followed by the bits you want to clear.

Examples:

 MorphOS:> Protect myfile +sr
 Sets the script and read bit of file 'myfile'

 MorphOS:> Protect #?.txt w SUB
 clears the write bit of all files matching pattern '#?.txt'