4 proc fileCanBeOverwritten { filename } {
5 global flagFileCanBeOverwritten
7 if { [file exists $filename ] } {
8 set t [ toplevel .overwriteChecker ]
9 label $t.label -text "$filename Can be overwritten ?"
10 button $t.ok -text Yes -command { set flagFileCanBeOverwritten yes }
11 button $t.no -text No -command { set flagFileCanBeOverwritten no }
12 pack $t.label $t.ok $t.no -side top
13 tkwait variable flagFileCanBeOverwritten
16 set flagFileCanBeOverwritten yes
18 return $flagFileCanBeOverwritten
22 # Get Relative Pathname
25 proc relativePathGet { absDir absPath } {
26 if { [ file exists $absPath ] } {
27 set listOfabsPath [ split [ file dirname $absPath ] / ]
28 set path [ file tail $absPath ]
30 set listOfabsPath [ split [ file dirname $absPath ] / ]
31 set path [ file tail $absPath ]
33 if { [ file isdirectory $absDir ] } {
34 if { 0 == [ string compare $absDir / ] } {
35 set listOfabsDir [ split $absDir / ]
37 set listOfabsDir [ split [ string trimright $absDir / ] / ]
40 puts "Something wrong as for absDir in relativePathGet"
44 set nOfabsPath [ llength $listOfabsPath ]
45 set nOfabsDir [ llength $listOfabsDir ]
48 for { set i 0 } { $i < $nOfabsPath && $i < $nOfabsDir } { incr i } {
49 if { 0 != [ string compare [ lindex $listOfabsPath $i ] \
50 [ lindex $listOfabsDir $i ] ] } {
57 for { set j $i } { $j < $nOfabsDir } { incr j } {
58 if { 0 == [ string length [ lindex $listOfabsDir $j ] ] } {
64 for { set j $i } { $j < $nOfabsPath } { incr j } {
65 append relPath [ lindex $listOfabsPath $j ]