proc _driveLetters {} {
# Return a list of mapped drive (volume) letters (in upper case).
foreach drive [list a b c d e f g h i j k l m n o p q r s t u v x y z] {
if {[catch {file stat ${drive}: dummy}] == 0} {
lappend drives [string toupper $drive]
}
}
return $drives
}
proc _fileLinesList {fn} {
# Returns the lines of a given file as a list.
set f [open $fn r]
set t [read $f [file size $fn]]
close $f
return [split $t \n]
}
proc _recurseFolders {folder} {
# This script will build a list of files in the pwd including files in subfolders.
# Append all the files to a list of files.
foreach i [glob -nocomplain -types f -directory $folder -- *] {
lappend list_of_files $i
}
# Foreach directory recurse this procedure.
foreach j [glob -nocomplain -types d -directory $folder -- *] {
set list_of_files [concat $list_of_files [_recurse_folders $j]]
}
# Return the list of all the files.
return $list_of_files
}
proc _defaultApp {extension} {
# Find the name of the default application for a given file extension.
# This procedure searches the "HKEY_CLASSES_ROOT" key in the Windows registry.
package require registry
if {[catch {set fileType [registry get "HKEY_CLASSES_ROOT\\$extension" ""]} ]} {
puts "There is no default application assigned to '${extension}' files."
return 0
} else {
if {[catch {set defaultExe [registry get "HKEY_CLASSES_ROOT\\${fileType}\\shell\\open\\command" ""]} ]} {
puts "The default executable name for '${extension}' is not defined in the registry."
return 0
} else {
return $defaultExe
}
}
}