REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 6-Feb-2009 Edit History  

REBOL 3 Concepts: Ports: File Permissions

Pending Revision

This document was written for R2 and has yet to be revised for R3.

When files are created by REBOL, default access permissions are set. On Windows and Macintosh systems files are created with full access privileges. On UNIX systems files are created with the permissions set to the current umask setting.

When using open or write to access a file the /allow refinement is used to set file access permissions.

The /allow refinement takes a block as an argument. This block can consist of any or all of the three words read, write and execute.

Operating System Restrictions

The /allow refinement will only set permissions on operating systems supporting the specified permission setting. If the operating system does not support a permission setting used, the setting will be ignored. For instance, files on UNIX systems may be set as executable (' execute ), but the Windows and Macintosh operating systems don't support this. When dealing with UNIX systems, permissions set using /allow will only set the user permissions. Using / allow will cause all access permissions to be removed for users and others.

To make a file read only, use open/allow, or write/allow with a read block.

write/allow %file.txt [read]

To make a file readable and executable:

open/allow %file.txt [read execute]

You can set similar permissions for write access:

write/allow %file.txt [read write]

To prevent any access to a file (for operating systems where this would make a difference) provide an empty permissions block:

write/allow %file.txt []

To permit full access:

write/allow %file [read write execute]


  TOC < Back Next > REBOL.com - WIP Wiki Feedback Admin