From Xojo Documentation
| This class is only available on macOS and Linux platforms.
For cross-platform development, use ＃If...＃Endif with the Target... specifiers to make sure you will not attempt to use this class on an incompatible platform.
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.
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:
|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:
|3||Write and Execute 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:
|7||Owner||Read, Write, and Execute permissions|
|6||Group||Read and Write permissions|
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 PushButton that sets the permissions for the file.
// on the checkbox states
// Make a new, cleared permissions object
Dim 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 GetOpenFolderItem
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