note 47803 added to function.is-writable
| From: | BrianR at osu1 dot php dot net | Date: | Tue, 30 Nov 2004 23:43:05 +0000 |
| Subject: | note 47803 added to function.is-writable | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81203@lists.php.net to get a copy of this message | ||
One snag I've found is that on Windows, CDROM drives are not 'read only' meaning that
if this function is only passed the drive letter for a CD drive, it will return true even though
fopen will fail and writing is not possible (does not matter if it is a burner or not).
As a workaround for a script of mine:
function read_only ($path) {
if (preg_match ("/^([A-Za-z]:)\\\\?/", $path, $match)) {
echo $match[1];
if ($writable = @fopen ($match[1] . ".writetest", 'w')) {
fclose ($writable);
unlink ($match[1] . ".writetest");
}
} else {
$writable = is_writable ($path);
}
return !$writable;
}
----
Manual Page -- http://www.php.net/manual/en/function.is-writable.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47803
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47803&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47803&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47803&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47803&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47803&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47803&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47803&report=yes
Search -- http://master.php.net/manage/user-notes.php