note 47968 deleted from ref.filesystem by sean

From: Date: Tue, 07 Dec 2004 16:46:08 +0000
Subject: note 47968 deleted from ref.filesystem by sean
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-81492@lists.php.net to get a copy of this message
Note Submitter: rupert at save9 dot com ---- In response to requiring a list of accessible drive letters available in Windows, I wrote the following routine (following a suggestion from my genius work colleague): <?php $drive_letters = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; $drives = explode(" ", $drive_letters); for ($idx = 0; $idx < count($drives); $idx++) { $drive = $drives[$idx] . ":\\"; if (file_exists($drive) or is_dir($drive)) { $acc_drives[] = $drive; } } ?> Note that using both file_exists and is_dir isn't necessary. One or the other is fine. This routine won't, however, recognise mapped network drives. Also note that if PHP already provides this functionality in an existing function I didn't discover it. I can use the results in array acc_drives in the opendir function to get a directory listing of that drive. This code isn't supposed to be perfect, just a guide to others trying to achieve the same thing. ---- Reason: bad code

« previous php.notes (#81492) next »