Library: File system utilities (OMVFS)
Import : omvfs.xmd

export external function change-permissions
                value string  path
      on        value directory  on-dir   optional
      to        value integer    mode
      modifying value integer    mask     optional
      contents  value switch     contents optional
                                          initial {contents-not-included}

Argument definitions

The file or directory whose permissions are to be changed.
A vfs.directory object. If a vfs.directory object is specified the path parameter is relative to the vfs.directory and must be expressed as a relative URL.
A union of the permissions to be set.
is a union of the permissions to be modified.
Specifies whether the permissions of the content of a directory are also to be changed. Values are vfs.contents-included or vfs.content-not-included. The default is vfs.contents-not-included.


You can use vfs.change-permissions to set or alter the permissions of a file or directory.

The following program sets the file "myfile.txt" to be readable by everybody, but only writable by its owner and other group members.

  import "omvfs.xmd" prefixed by vfs.
  vfs.change-permissions "myfile.txt"
    to (vfs.permit-all-read union vfs.permit-user-write union vfs.permit-group-write)

The following program turns off the archive attribute of directory "testdir" and all its contents.

  import "omvfs.xmd" prefixed by vfs.
  vfs.change-permissions "testdir" to 0 modifying vfs.permit-archive
     contents vfs.contents-included

The following constants are usable for the mode and mask parameters. Multiple attributes can be set at once by creating a union.


If any of permit-user-write, permit-group-write and permit-other-write is set on Windows, then they are all set due to OS limitations.

Some UNIX systems do not allow non-root users to set permit-sticky.

Attributes not supported by a particular OS will be ignored.

If mask is not specified, then the target's permissions are changed to match those specified in mode.

If mask is specified, then only the permissions specified in the mask will be modified to the matching values in mode.

If contents is set to contents-included and the target is a directory, then the directory along with its contents will be changed recursively to the specified permissions.


The following exceptions may occur: