vfsChangePermissions

function

Library: File system utilities (OMVFS legacy)
Include: omvfs.xin

Declaration
define external function vfsChangePermissions
                value string  path
      to        value integer mode
      modifying value integer mask       (optional)
      contents  value switch  contents   (optional)

or

define external function vfsChangePermissions
                value string  filename-URL
      on        value vfsDir  dir
      to        value integer mode
      modifying value integer mask       (optional)
      contents  value switch  contents   (optional)

Argument definitions

path
is the file or directory in local file system format whose permissions are to be changed.
filename-URL
is the name of the file whose permissions are to be changed expressed as a relative URL using the specified vfsDir object as its base.
dir
is a vfsDir object created using either vfsConnect or vfsConnectDir.
mode
is a union of the permissions we wish to enable on the file or directory.
mask
is a union of the permissions we wish to modify on the file or directory.
contents
is a flag indicating whether we should change permissions recursively if the target is a directory. The default value is VFS-NOT-INCLUDED.


Purpose

Use vfsChangePermissions to set or alter the permissions of a file or directory.

Requirements

You must include the following line at the beginning of your OmniMark program:

  include "omvfs.xin"

path must:

filename-URL must:

The vfsDir object dir must:

Usage Notes

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 VFS-ATTR-USER-WRITE, VFS-ATTR-GROUP-WRITE and VFS-ATTR-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 VFS-ATTR-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 VFS-INCLUDED and the target is a directory, then the directory along with its contents will be changed recursively to the specified permissions.

External exception VFS300 is thrown for any general OS operation failure. The text accompanying the exception will contain details on the reason for the failure.

External exception VFS111 is thrown if an URL supplied as a parameter to this function contains invalid encoding.

External exception VFS004 is thrown if the URL exceeds system length limits.

For complete details on absolute URLs and valid encoding, see Internet Standards RFC 1738: Uniform Resource Locators.

For complete details on relative URLs, see Internet Standards RFC 1808: Relative Uniform Resource Locators.

Example #1 (UNIX)

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

  vfsChangePermissions "myfile.txt"
    to (VFS-ATTR-ALL-READ union VFS-ATTR-USER-WRITE union VFS-ATTR-GROUP-WRITE)

Example #2 (Windows)

Turn off the archive attribute of directory "testdir" and all its contents.

  vfsChangePermissions "testdir" to 0 modifying VFS-ATTR-ARCHIVE
     contents VFS-INCLUDED