Class

# Permissions

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Enables you to test, set, and clear the <span class="title-ref">Permissions</span> of `FolderItems</api/files/folderitem>` in operating systems that support this concept (macOS and Linux). You can get and set the <span class="title-ref">Permissions</span> of a `FolderItem</api/files/folderitem>` as an octal `Integer</api/data_types/integer>` via the <span class="title-ref">Permissions</span> property of the `FolderItem</api/files/folderitem>` class.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                       | Type                               | Read-Only | Shared |
|--------------------------------------------|------------------------------------|-----------|--------|
| `GidBit<permissions.gidbit>`               | `Boolean</api/data_types/boolean>` |           |        |
| `GroupExecute<permissions.groupexecute>`   | `Boolean</api/data_types/boolean>` |           |        |
| `GroupRead<permissions.groupread>`         | `Boolean</api/data_types/boolean>` |           |        |
| `GroupWrite<permissions.groupwrite>`       | `Boolean</api/data_types/boolean>` |           |        |
| `OthersExecute<permissions.othersexecute>` | `Boolean</api/data_types/boolean>` |           |        |
| `OthersRead<permissions.othersread>`       | `Boolean</api/data_types/boolean>` |           |        |
| `OthersWrite<permissions.otherswrite>`     | `Boolean</api/data_types/boolean>` |           |        |
| `OwnerExecute<permissions.ownerexecute>`   | `Boolean</api/data_types/boolean>` |           |        |
| `OwnerRead<permissions.ownerread>`         | `Boolean</api/data_types/boolean>` |           |        |
| `OwnerWrite<permissions.ownerwrite>`       | `Boolean</api/data_types/boolean>` |           |        |
| `StickyBit<permissions.stickybit>`         | `Boolean</api/data_types/boolean>` |           |        |
| `UidBit<permissions.uidbit>`               | `Boolean</api/data_types/boolean>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                    | Parameters                                  | Returns | Shared |
|-----------------------------------------|---------------------------------------------|---------|--------|
| `Constructor<permissions.constructor0>` | perms As `Integer</api/data_types/integer>` |         |        |

## Property descriptions

<div id="permissions.gidbit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.GidBit

**GidBit** As `Boolean</api/data_types/boolean>`

> Set Group ID bit. If `True</api/language/true>`, the current user has the <span class="title-ref">Permissions</span> of the owning Group without altering the Read/Write/Execute <span class="title-ref">Permissions</span> for the `FolderItem</api/files/folderitem>`.

<div id="permissions.groupexecute">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.GroupExecute

**GroupExecute** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, a member of the Group that owns the `FolderItem</api/files/folderitem>` can execute the `FolderItem</api/files/folderitem>`.

<div id="permissions.groupread">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.GroupRead

**GroupRead** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, a member of the Group that owns the `FolderItem</api/files/folderitem>` can read the `FolderItem</api/files/folderitem>`.

<div id="permissions.groupwrite">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.GroupWrite

**GroupWrite** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, a member of the Group that owns the `FolderItem</api/files/folderitem>` can write to the `FolderItem</api/files/folderitem>`.

<div id="permissions.othersexecute">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.OthersExecute

**OthersExecute** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, a user outside the Group that owns the `FolderItem</api/files/folderitem>` can execute the `FolderItem</api/files/folderitem>`.

<div id="permissions.othersread">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.OthersRead

**OthersRead** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, a user outside the Group that owns the `FolderItem</api/files/folderitem>` can read the `FolderItem</api/files/folderitem>`.

<div id="permissions.otherswrite">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.OthersWrite

**OthersWrite** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, a user outside the Group that owns the `FolderItem</api/files/folderitem>` can write to the `FolderItem</api/files/folderitem>`.

<div id="permissions.ownerexecute">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.OwnerExecute

**OwnerExecute** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the owner of the `FolderItem</api/files/folderitem>` can execute the `FolderItem</api/files/folderitem>`.

<div id="permissions.ownerread">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.OwnerRead

**OwnerRead** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the owner of the `FolderItem</api/files/folderitem>` can read the `FolderItem</api/files/folderitem>`.

<div id="permissions.ownerwrite">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.OwnerWrite

**OwnerWrite** As `Boolean</api/data_types/boolean>`

> If `True</api/language/true>`, the owner of the `FolderItem</api/files/folderitem>` can write to the `FolderItem</api/files/folderitem>`.

<div id="permissions.stickybit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.StickyBit

**StickyBit** As `Boolean</api/data_types/boolean>`

> If `True</api/language/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 <span class="title-ref">Permissions</span>.
>
> 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</api/files/folderitem>` <span class="title-ref">Permissions</span>.

<div id="permissions.uidbit">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.UidBit

**UidBit** As `Boolean</api/data_types/boolean>`

> Set User ID bit. If `True</api/language/true>`, the current user has the <span class="title-ref">Permissions</span> of the owner without altering the Read/Write/Execute <span class="title-ref">Permissions</span> for the `FolderItem</api/files/folderitem>`.

## Method descriptions

<div id="permissions.constructor0">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Permissions.Constructor

**Constructor**(perms As `Integer</api/data_types/integer>`)

> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> `Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.
>
> </div>
>
> Creates a <span class="title-ref">Permissions</span> instance with the passed <span class="title-ref">perms</span>. The value is base 8 and can be specified using the octal keyword (`&o</api/language/literals/o>`).
>
> See the Notes section for <span class="title-ref">Permissions</span> and the `FolderItem.Permissions<folderitem.permissions>` entry for the tables used to set the octal value of <span class="title-ref">perms</span>. Pass the octal value that corresponds to the desired <span class="title-ref">Permissions</span> level. You can also pass a zero and then assign <span class="title-ref">Permissions</span>. This is shown in the first example of the <span class="title-ref">Permissions</span> class.
>
> The following example gives the owner Read, Write and Execute privileges:
>
> ``` xojo
> Var p As New Permissions(&o644)
> p.OwnerRead = True
> p.OwnerWrite = True
> p.OwnerExecute = True
> ```

## Notes

On Unix-based operating systems, <span class="title-ref">Permissions</span> 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 <span class="title-ref">Permissions</span> of the `FolderItem</api/files/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 <span class="title-ref">permissions</span>    | User or group can open and read the `FolderItem</api/files/folderitem>`.     |
| 2     | Write <span class="title-ref">permissions</span>   | User or group can open and write to the `FolderItem</api/files/folderitem>`. |
| 1     | Execute <span class="title-ref">permissions</span> | User or group can execute the file or read the directory.                    |

For directories, Execute <span class="title-ref">Permissions</span> 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 <span class="title-ref">Permissions</span> are expressed by adding up the values. Each digit can take on eight possible values:

| Value | Description                                                         |
|-------|---------------------------------------------------------------------|
| 0     | No <span class="title-ref">permissions</span>                       |
| 1     | Execute <span class="title-ref">permissions</span>                  |
| 2     | Write <span class="title-ref">permissions</span>                    |
| 3     | Write and Execute <span class="title-ref">permissions</span>        |
| 4     | Read <span class="title-ref">permissions</span>                     |
| 5     | Read and Execute <span class="title-ref">permissions</span>         |
| 6     | Read and Write <span class="title-ref">permissions</span>           |
| 7     | Read, Write, and Execute <span class="title-ref">permissions</span> |

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

| Value | User Type | Description                                                         |
|-------|-----------|---------------------------------------------------------------------|
| 7     | Owner     | Read, Write, and Execute <span class="title-ref">permissions</span> |
| 6     | Group     | Read and Write <span class="title-ref">permissions</span>           |
| 4     | Others    | Read <span class="title-ref">permissions</span>                     |

## Sample code

The following example sets the <span class="title-ref">Permissions</span> 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 <span class="title-ref">Permissions</span> of the file. This code is in a `Button</api/user_interface/desktop/desktopbutton>` that sets the <span class="title-ref">Permissions</span> for the file.

``` xojo
' 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

|                       |                               |
|-----------------------|-------------------------------|
| **Project Types**     | Console, Desktop, Mobile, Web |
| **Operating Systems** | iOS, Linux, macOS, Windows    |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `FolderItem</api/files/folderitem>` class.

</div>
