CHMOD

Portability Function: Changes the access mode of a file.

Module: USE DFPORT

Syntax

result = CHMOD (name, mode)

name
(Input) Character*(*). Name of the file whose access mode is to be changed. Must have a single path.


mode
(Input) Character*(*). File permission: either Read, Write, or Execute. The mode parameter can be either symbolic or absolute. An absolute mode is specified with an octal number, consisting of any combination of the following permission bits ORed together:


Permission bit Description Action
4000 Set user ID on execution Ignored; never true
2000 Set group ID on execution Ignored; never true
1000 Sticky bit Ignored; never true
0400 Read by owner Ignored; always true
0200 Write by owner Settable
0100 Execute by owner Ignored; based on filename extension
0040, 0020, 0010 Read, Write, Execute by group Ignored; assumes owner permissions
0004, 0002, 0001 Read, Write, Execute by others Ignored; assumes owner permissions

The following regular expression represents a symbolic mode:

[ugoa]*[+-=] [rwxXst]* 

"[ugoa]*" is ignored. "[+ - =]" indicates the operation to carry out:

+ Add the permission
- Remove the permission
= Absolutely set the permission

"[rwxXst]*" indicates the permission to add, subtract, or set. Only "w" is significant and affects write permission. All other letters are ignored.

Results:

INTEGER(4). Zero if the mode was changed successfully; otherwise, an error code. Possible error codes are:

Compatibility

CONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS DLL LIB

See Also: SETFILEACCESSQQ

Example

USE DFPORT
integer(4) I,Istatus
I = ACCESS ("DATAFILE.TXT", "w")
if (i) then
   ISTATUS = CHMOD ("datafile.txt", "[+w]")
end if
I = ACCESS ("DATAFILE.TXT","w")
print *, i