note 47803 deleted from function.is-writable by sean

From: Date: Tue, 14 Dec 2004 05:47:46 +0000
Subject: note 47803 deleted from function.is-writable by sean
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-81774@lists.php.net to get a copy of this message
Note Submitter: Brian R ---- 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; }

« previous php.notes (#81774) next »