<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../style.css">
<title>
Gambas Documentation - Access
</title>
</head>
<table class="none" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td align="left">
<font size="-1">
<a href="../../help+en"><img class="flag" alt="Home" border="0" src="../../img/lang/en.png" align="center"></a>&nbsp;
<a href="../lang+en">Up</a>&nbsp;
<a href="abs+en">Previous</a>&nbsp;
<a href="acos+en">Next</a>&nbsp;
</td></tr></table>
<div class="notab">
<h1>
Access
</h1>
<div class="black"><font size="-2"><b>Syntax</b></font></div>
<pre class="syntax"><u>Accessible</u> <b>= Access (</b> <u>Path</u> <b>AS String</b> [ <b>,</b> <u>Mode</u> <b>AS Integer</b> ] <b>) AS Boolean</b></pre><p>

Returns <a href="true+en">TRUE</a> if the file specified by <u>Path</u> is accessible by the mode specified by <u>Mode</u> .
<p>
If the value of <u>Mode</u> is:
<ul>
<li><a href="../comp/gb/gb+en">gb</a>.<a href="../comp/gb/gb/read+en">Read</a>, then returns <a href="true+en">TRUE</a> if the file can be read.
<li><a href="../comp/gb/gb+en">gb</a>.<a href="../comp/gb/gb/write+en">Write</a>, then returns <a href="true+en">TRUE</a> if the file can be written.
<li><a href="../comp/gb/gb+en">gb</a>.<a href="../comp/gb/gb/exec+en">Exec</a>, then returns <a href="true+en">TRUE</a> if the file can be executed.
<p>
</ul>

The previous flags can be combined with the <a href="or+en">OR</a> operator.
<p>
<ul>
<li><a href="../comp/gb/gb+en">gb</a>.<a href="../comp/gb/gb/read+en">Read</a>, is the default behavior when the optional agrument <u>Mode</u> is not specified.
<p>
</ul>

For a directory, the execution flag means that the directory may be browsed.
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Access(&quot;/home/benoit&quot;, gb.Write OR gb.Exec)
<hr>True</pre>
<p>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PUBLIC SUB Button1_Click()
DIM sPath AS String

sPath = &quot;/root/bin&quot;
PRINT sPath; &quot; RW &quot;; Access(sPath, gb.Read OR gb.write)
PRINT sPath; &quot; R  &quot;; Access(sPath, gb.Read)
PRINT sPath; &quot;  W &quot;; Access(sPath, gb.write)
PRINT sPath; &quot;    &quot;; Access(sPath)

END
<hr>/root/bin RW False
/root/bin R  True
/root/bin  W False
/root/bin    True</pre>
<p>
<div class="warning"><table class="none" border="0"><tr><td width="40" valign="top"><img border="0" src="../../img/warning.png" align="center"></td><td valign="top">
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(&quot;img/myImage.png&quot;) will never return <a href="../comp/gb/gb+en">gb</a>.<a href="../comp/gb/gb/write+en">Write</a>).  Use tempfiles or create a special directory (dotfile) in the active user (ie: user running the <a href="../def/gambas+en">Gambas</a> program) home directory.
</td></tr></table></div>
<div class="gray"><font size="-2"><b>Example</b></font></div>
<pre class="example">PRINT Access(&quot;data/img/myImage.png&quot;, gb.Write)
<hr>False
<hr>Even after performing: <b>chmod 777 &quot;PathToMyProject/img/myImage.png&quot;</b></pre>
<p>

<hr><b>See also</b><br>
<a href="../cat/file+en">File &amp; Directory Functions</a>&nbsp;

</div>
</body>
</html>

