Finding available drives

I did a little disk tree scanner for an upload/download site and was attempting to make it a little more robust by allowing me to scan not only all directories of a drive, but all drives.

I cannot find any way to list logical drives. Searching PHP.net and Google didn’t help. I know it would be a lot different on different platforms, but for this instance I’m looking at a Windows solution. Besides doing a loop and is_dir() root on c, d, e, f, g… etc, are there any functions or ideas for listing logical drives themselves?

Actually - for windows this is pretty quick and dirty but works. If anyone can think of a better solution, shout.
[php]<?PHP
function getDrives()
{
$drives = array();

for($l = ord("A"); $l <= ord("Z"); $l++)
{
	$letter = chr($l);

	if(is_dir($letter . ":/"))
	{
		$drives[] = $letter;
	}
}
if(count($drives) < 1) $drives = NULL;

return $drives;

}
?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service