Req #52647 [Asn->Opn]: Function to get Windows drive letters

From: Date: Tue, 24 Oct 2017 07:35:19 +0000
Subject: Req #52647 [Asn->Opn]: Function to get Windows drive letters
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212114@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=52647&edit=1 ID: 52647 Updated by: kalle@php.net Reported by: shaun dot spiller at yahoo dot com Summary: Function to get Windows drive letters -Status: Assigned +Status: Open Type: Feature/Change Request Package: Filesystem function related Operating System: Windows PHP Version: 5.3.3 -Assigned To: pajoye +Assigned To: Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2012-07-31 19:30:31] sodijfsdoifjsoidfj at osidjfoidsfj dot com This does it in PHP-only code, but it takes about half a second to load the COM object, so it's probably no use except in long-running CLI scripts, or unless you cache the result for a while. function filesys_get_roots() { static $roots = null; if ($roots === null) { if (strncasecmp(PHP_OS, 'WIN', 3) === 0) { $fso = new COM('Scripting.FileSystemObject'); foreach ($fso->Drives as $drive) { $roots[] = $drive->DriveLetter . ':\\'; } } else { $roots = array('/'); } } return $roots; } Really the function needs to be in the PHP core. ------------------------------------------------------------------------ [2011-10-27 20:14:53] shaun dot spiller at yahoo dot com @fate at jehy dot ru 'Twas the very first thing I tried. The problem is it spins up sleeping drives. For the floppy drive it had the particularly nasty effect of displaying this message on the desktop: "Windows - No Disk: There is no disk in the drive. Please insert a disk into drive. Cancel / Try Again / Continue". That's not very good in CLI and certainly no good in a web server environment, and I was making a remote file access script, you see. It needed a proper API call, one way or another. ------------------------------------------------------------------------ [2011-10-27 12:11:29] pajoye@php.net @fate at jehy dot ru it could be handy and it costs less to do it using the system's API direclty. ------------------------------------------------------------------------ [2011-10-27 11:56:43] fate at jehy dot ru So useless. function get_drives() { $d='ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $drives=''; for($i=0;$i<strlen($d);$i++) if(is_dir($d[$i].':\\')) $drives.=$d[$i]; echo $drives; } ------------------------------------------------------------------------ [2011-05-26 23:53:20] asdasdioj at asdojiojasd dot asdasd I check back here every day for progress. Never happens. I'm non-plussed as to how this feature got overlooked for so long, or what mythical issues pajoye thinks there are with my lovely code. :-( ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=52647 -- Edit this bug report at https://bugs.php.net/bug.php?id=52647&edit=1

« previous php.bugs (#212114) next »