Gambas Documentation - /lang/access

/lang/access

# Access

Accessible = Access ( Path [ , Mode ] )

Return TRUE if the file specified by Path is accessible by the mode specified by Mode.

If the value of Mode is:

- `gb.Read`, then return TRUE if the file can be read.

- `gb.Write`, then return TRUE if the file can be written.

- `gb.Exec`, then return TRUE if the file can be executed.

The previous flags can be combined with the OR operator.

- `gb.Read` is the default behavior when the optional argument Mode is not specified.

For a directory, the execution flag means that the directory may be browsed.

### Examples

    Print Access("/home/benoit", gb.Write OR gb.Exec)

    True

    Dim sPath As String

    sPath = "/root/bin"
    Print sPath; " RW "; Access(sPath, gb.Read Or gb.write)
    Print sPath; " R  "; Access(sPath, gb.Read)
    Print sPath; "  W "; Access(sPath, gb.write)
    Print sPath; "    "; Access(sPath)

    /root/bin RW False
    /root/bin R  True
    /root/bin  W False
    /root/bin    True

All files under the project directory (including any subdirectories created under the project directory) are treated as read-only despite any actual mode settings, even files set to permission mode `777` (full access read-and-write for owner, group and world), (ie: `Access("img/myImage.png")` will never return `gb.Write`).

Here is the reason: when making the executable, all project files are put inside the executable file, and so cannot be modified at runtime.

Use temporary files or create a special directory (dotfile) in the current user home directory.

    Print Access("data/img/myImage.png", gb.Write)

    False ' Even after performing: chmod 777 "PathToMyProject/img/myImage.png"

### See also

- File & Directory Functions