file : add the methods is_readable, is_writeable, is_executable
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3332 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
44
file.php
44
file.php
@@ -265,6 +265,50 @@ class file
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Tells whether a file exists and is writeable
|
||||
* @param string $filename The filename to test
|
||||
* @return bool true if the $filename is a file exists and is writeable
|
||||
* @throws If parent directory not exists, or is not executable
|
||||
*/
|
||||
public function is_executable ($filename)
|
||||
{
|
||||
$this->debug (2, "is_executable ($filename)");
|
||||
$filename = $this->realpath ($filename);
|
||||
$this->checkPathRO (dirname ($filename));
|
||||
if (file_exists ($filename) && is_executable ($filename))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Tells whether a file exists and is readable
|
||||
* @param string $filename The filename to test
|
||||
* @return bool true if the $filename is a file exists and is readable
|
||||
* @throws If parent directory not exists, or is not executable
|
||||
*/
|
||||
public function is_readable ($filename)
|
||||
{
|
||||
$this->debug (2, "is_readable ($filename)");
|
||||
$filename = $this->realpath ($filename);
|
||||
$this->checkPathRO (dirname ($filename));
|
||||
if (file_exists ($filename) && is_readable ($filename))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Tells whether a file exists and is writeable
|
||||
* @param string $filename The filename to test
|
||||
* @return bool true if the $filename is a file exists and is writeable
|
||||
* @throws If parent directory not exists, or is not executable
|
||||
*/
|
||||
public function is_writeable ($filename)
|
||||
{
|
||||
$this->debug (2, "is_writeable ($filename)");
|
||||
$filename = $this->realpath ($filename);
|
||||
$this->checkPathRO (dirname ($filename));
|
||||
if (file_exists ($filename) && is_writeable ($filename))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Lock a file exclusively
|
||||
* @param string $filename The file to lock
|
||||
|
||||
Reference in New Issue
Block a user