Class

Permissions


Description

Enables you to test, set, and clear the Permissions of FolderItems in operating systems that support this concept (macOS and Linux). You can get and set the Permissions of a FolderItem as an octal Integer via the Permissions property of the FolderItem class.

Methods

Name

Parameters

Returns

Shared

Constructor

perms As Integer

Property descriptions


Permissions.GidBit

GidBit As Boolean

Set Group ID bit. If True, the current user has the Permissions of the owning Group without altering the Read/Write/Execute Permissions for the FolderItem.


Permissions.GroupExecute

GroupExecute As Boolean

If True, a member of the Group that owns the FolderItem can execute the FolderItem.


Permissions.GroupRead

GroupRead As Boolean

If True, a member of the Group that owns the FolderItem can read the FolderItem.


Permissions.GroupWrite

GroupWrite As Boolean

If True, a member of the Group that owns the FolderItem can write to the FolderItem.


Permissions.OthersExecute

OthersExecute As Boolean

If True, a user outside the Group that owns the FolderItem can execute the FolderItem.


Permissions.OthersRead

OthersRead As Boolean

If True, a user outside the Group that owns the FolderItem can read the FolderItem.


Permissions.OthersWrite

OthersWrite As Boolean

If True, a user outside the Group that owns the FolderItem can write to the FolderItem.


Permissions.OwnerExecute

OwnerExecute As Boolean

If True, the owner of the FolderItem can execute the FolderItem.


Permissions.OwnerRead

OwnerRead As Boolean

If True, the owner of the FolderItem can read the FolderItem.


Permissions.OwnerWrite

OwnerWrite As Boolean

If True, the owner of the FolderItem can write to the FolderItem.


Permissions.StickyBit

StickyBit As Boolean

If True, the operating system will not allow someone to remove or rename the file or files in the directory that he does not own, even he has Read/Write Permissions.

This can be used for directories in which different users need to be able to create files but should not touch others' files. If the StickyBit is set, a 1 appears to the left of the Owner's digit in the Octal representation of the FolderItem's Permissions.


Permissions.UidBit

UidBit As Boolean

Set User ID bit. If True, the current user has the Permissions of the owner without altering the Read/Write/Execute Permissions for the FolderItem.

Method descriptions


Permissions.Constructor

Constructor(perms As Integer)

Note

Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.

Creates a Permissions instance with the passed perms. The value is base 8 and can be specified using the octal keyword (&o).

See the Notes section for Permissions and the FolderItem.Permissions entry for the tables used to set the octal value of perms. Pass the octal value that corresponds to the desired Permissions level. You can also pass a zero and then assign Permissions. This is shown in the first example of the Permissions class.

The following example gives the owner Read, Write and Execute privileges:

Var p As New Permissions(&o644)
p.OwnerRead = True
p.OwnerWrite = True
p.OwnerExecute = True

Notes

On Unix-based operating systems, Permissions can be represented as a three-digit numeric code, in which each digit ranges from 0 to 7 (a.k.a, an octal number). The digits correspond to the Permissions of the FolderItem Owner, the owning Group, and Other users not in the owning Group, in that order, from left to right.

The code for each digit is computed using the following values:

Value

Permission Type

Description

4

Read permissions

User or group can open and read the FolderItem.

2

Write permissions

User or group can open and write to the FolderItem.

1

Execute permissions

User or group can execute the file or read the directory.

For directories, Execute Permissions means that the user or group can list the contents of the directory and examine the files that the user has permission to read.

For each digit, the Permissions are expressed by adding up the values. Each digit can take on eight possible values:

Value

Description

0

No permissions

1

Execute permissions

2

Write permissions

3

Write and Execute permissions

4

Read permissions

5

Read and Execute permissions

6

Read and Write permissions

7

Read, Write, and Execute permissions

For example, the code "764" is interpreted as follows:

Value

User Type

Description

7

Owner

Read, Write, and Execute permissions

6

Group

Read and Write permissions

4

Others

Read permissions

Sample code

The following example sets the Permissions for a file. It is for Unix-based operating systems only. Twelve checkboxes on the layout enable the user to set or deselect each type of permission. When the file is opened, these checkboxes are set by reading the current Permissions of the file. This code is in a Button that sets the Permissions for the file.

' The user wants to set the permissions based
' on the checkbox states

' Make a new, cleared permissions object
Var p As New Permissions(0)

//And set the permissions by reading the CheckBoxes
p.StickyBit = CheckBox1.Value
p.UidBit = CheckBox2.Value
p.GidBit = CheckBox3.Value
p.OwnerExecute = CheckBox4.Value
p.OwnerWrite = CheckBox5.Value
p.OwnerRead = CheckBox6.Value
p.GroupExecute = CheckBox7.Value
p.GroupWrite = CheckBox8.Value
p.GroupRead = CheckBox9.Value
p.OthersExecute = CheckBox10.Value
p.OthersWrite = CheckBox11.Value
p.OthersRead = CheckBox12.Value

' Set the file's permissions
' mFile is the file that was opened with FolderItem.ShowOpenFileDialog
mFile.Permissions = p

' And display the octal value
TextField1.Text = Oct(mFile.Permissions)

' Display the owner and group as well
TextField2.Text = mFile.Group
TextField3.Text = mFile.Owner

Compatibility

All project types on all supported operating systems.

See also

Object parent class; FolderItem class.