Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can Tcl determine between a CDROM and Hardrive?

Status
Not open for further replies.

hija

Programmer
Oct 30, 2002
16
AU
I am trying to create a procedure that searches the PC to find out what Drives [logical] exist on a system.
This is in a windows environment.
The reason is to be able to search for a specific directory that should exist on the PC.

So using :
set volumes [file volume]
regsub {\s} $volumes {} drives
set drive [split drives /]

gets me the drive list, then using a foreach loop I can use
cd $drive
and then

if {[file exists "FindDirectory"] == 1 }{
'do something in that directory'
}

This works fine until I reach a CDROM drive at which point Tcl says it cannot change directory to this drive and so grinds to a halt..

Is there some way I can get Tcl to skip over the CDROM by recognising it is not a writable device or some other parameter that can be used so the loop can be caused to skip over it using 'continue'
 
Why don't you use file writable?
if {[file exists $filename] && [file writable $filename]} {
do something..
}
 
marsd,
thanks marsd this works fine in fact I did not need the 'file exists' bit I just need to be able to make the proc skip over looking at the cdrom, as the directory in question will always reside on a hardrive but i could not guaruntee that it will always be on the HOME or SystemDrive hence the need to search all volumes that might exist.

hija
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top