Setting access permissions of a file or directoryΒΆ
chmod() |
Set access permissions of a file or directory |
SYNTAX
chmod(pathname, mode)
Sets the access permissions for a file or directory. Only the existing owner or the superuser can change permissions.
pathname |
The path of the file or directory. |
||||||||||||||||||
mode |
The permissions to be set. The possible values for mode are defined in the standard include file $SCULPTOR/include/files.h, and are as follows:
These modes can be combined using the | operator. Common combinations of the modes are also defined in $SCULPTOR/include/files.h. This argument is ignored for directories under MSDOS/Windows, but should be set to a sensible value in case this changes in the future. |
The function returns zero if successful; otherwise it returns -1 and assigns the operating system error code to sys.Errno.
UNIX supports all the modes listed above, and has the additional feature that if mode is set to 0 all permissions are removed.
MS-DOS and Windows support only PERMS_RDOWNER and PERMS_WROWNER; all other modes are ignored. Files can always be read under DOS and Windows, so the mode PERMS_RDOWNER is always set, whether or not it is specified.
EXAMPLE
chmod("/sys/errlog", PERMS_RDOTHER | PERMS_EXOTHER)
RELATED TOPICS |