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:

  • exist (else external exception VFS306)
  • be a file or a directory
  • be expressed in local file system format as either
    • an absolute path, or
    • a path relative to the current working directory for the local file system

filename-URL must:

  • exist (else external exception VFS306)
  • be a file or a directory
  • be expressed as a relative URL based on the current working directory for dir (else external exception VFS105)

The vfsDir object dir must:

  • represent an existing connection made using vfsConnect or vfsConnectDir (else external exception VFS100)
  • represent a connection made using the File scheme (else external exception VFS001)

Usage Notes

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

  • Common to Windows and Unix
    • VFS-ATTR-OTHER-WRITE
    • VFS-ATTR-GROUP-WRITE
    • VFS-ATTR-USER-WRITE
  • UNIX specific
    • VFS-ATTR-OTHER-EXECUTE
    • VFS-ATTR-OTHER-READ
    • VFS-ATTR-GROUP-EXECUTE
    • VFS-ATTR-GROUP-READ
    • VFS-ATTR-USER-EXECUTE
    • VFS-ATTR-USER-READ
    • VFS-ATTR-STICKY
    • VFS-ATTR-SETGID
    • VFS-ATTR-SETUID
  • Windows specific
    • VFS-ATTR-SYSTEM
    • VFS-ATTR-ARCHIVE
    • VFS-ATTR-HIDDEN
    • VFS-ATTR-TEMPORARY
    • VFS-ATTR-OFFLINE
  • Convenience constants constructed from the first set of constants
    • VFS-ATTR-ALL-READ (Unix only)
    • VFS-ATTR-ALL-WRITE (Common to both Windows and Unix)
    • VFS-ATTR-ALL-EXECUTE (Unix only)

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

Other Library Functions

AltStyle によって変換されたページ (->オリジナル) /