Home / lang / access 
Access
Syntax
Accessible = Access ( Path AS String [ , Mode AS Integer ] ) AS Boolean

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

If the value of Mode is:

The previous flags can be combined with the OR operator.

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

Examples

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

True

PUBLIC SUB Button1_Click()
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)

END

/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). Use tempfiles or create a special directory (dotfile) in the active user (ie: user running the Gambas program) 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