chanklaus has asked for the wisdom of the Perl Monks concerning the following question:
for a program running on a Windows OS I want to have a list of all device letters for devices containing a browsable directory structure (eg. "c:", "d:", etc).
This can be done by creating all possible drive letters and testing whether the respective drive letter is available as a drive. I wrote a function doing exactly that:
sub DriveList { my (@Drives,$Char); $Char = "b"; until ($Char eq "z") { ++$Char; if ((-d "$Char:\\") && (-w "$Char:\\")) { push(@Drives,sprintf("%s:",$Char)); } } @Drives; }
This works quite fine, except for those drives containing floppys: if there is no floppy inserted a window will pop up saying that a floppy has to be inserted, and that is obviously annoying. One possibility would be to just exclude letters "a:" and "b:", which are usually reserved for the floppys (as I did in the function above) - rather a workaround than a solution.
Now, this would still be good enough for me, but I recently found out that inserted UMTS sticks can have the same effect, so again an error window pops up, asking for the insertion of a data medium - and they won't have a letter I can exclude, but can appear anvwhere in the list of possible characters.
Could anybody tell me how to change my function to be equipped to deal with those floppy and USB device problems? Or even suggest a real solution?
Many thanks in advance, and wishing you all a good time, Yours
chanklaus
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating a drive list on a Windows system?
by Anonymous Monk on Nov 06, 2009 at 09:32 UTC | |
|
Re: Creating a drive list on a Windows system?
by Marshall (Canon) on Nov 07, 2009 at 18:22 UTC |