43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
return -1
}
return 1
}
# Compare two files or dirs
# Return true if equal
proc CompareFiles {file1 file2} {
if {[catch {file lstat $file1 stat1}]} {
return 0
}
if {[catch {file lstat $file2 stat2}]} {
return 0
}
# Same type?
set isdir1 [FileIsDirectory $file1]
set isdir2 [FileIsDirectory $file2]
if {$isdir1 != $isdir2} {
return 0
}
# Handle links
if {$stat1(type) eq "link" && $stat2(type) eq "link"} {
set l1 [file link $file1]
set l2 [file link $file2]
# Equal links are considered equal, otherwise check contents
if {$l1 eq $l2} {
return 1
}
file stat $file1 stat1
file stat $file2 stat2
}
# If contents is not checked, same size is enough to be equal
if {$stat1(size) == $stat2(size) && $::Pref(dir,comparelevel) == 0} {
return 1
}
set ignorekey $::Pref(dir,ignorekey)
# Different size is enough when doing binary compare
if {$stat1(size) != $stat2(size) && $::Pref(dir,comparelevel) == 2 \
&& !$ignorekey} {
return 0
}
# Same size and time is always considered equal
if {$stat1(size) == $stat2(size) && $stat1(mtime) == $stat2(mtime)} {
return 1
}
# Don't check further if contents should not be checked
if {$::Pref(dir,comparelevel) == 0} {
return 0
}
# Don't check further if any is a directory
|
|
|
|
>
>
>
>
>
>
>
>
|
|
|
>
>
>
>
|
|
|
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
return -1
}
return 1
}
# Compare two files or dirs
# Return true if equal
proc CompareFiles {fileD1 fileD2} {
if {[dict size $fileD1] == 0} {
return 0
}
if {[dict size $fileD2] == 0} {
return 0
}
set file1 [dict get $fileD1 full]
set file2 [dict get $fileD2 full]
set type1 [dict get $fileD1 type]
set type2 [dict get $fileD2 type]
set size1 [dict get $fileD1 size]
set size2 [dict get $fileD2 size]
set mtime1 [dict get $fileD1 mtime]
set mtime2 [dict get $fileD2 mtime]
# Same type?
set isdir1 [dict get $fileD1 dir]
set isdir2 [dict get $fileD2 dir]
if {$isdir1 != $isdir2} {
return 0
}
# Handle links
if {$type1 eq "link" && $type2 eq "link"} {
set l1 [file link $file1]
set l2 [file link $file2]
# Equal links are considered equal, otherwise check contents
if {$l1 eq $l2} {
return 1
}
file stat $file1 stat1
file stat $file2 stat2
set size1 $stat1(size)
set size2 $stat2(size)
set mtime1 $stat1(mtime)
set mtime2 $stat2(mtime)
}
# If contents is not checked, same size is enough to be equal
if {$size1 == $size2 && $::Pref(dir,comparelevel) == 0} {
return 1
}
set ignorekey $::Pref(dir,ignorekey)
# Different size is enough when doing binary compare
if {$size1 != $size2 && $::Pref(dir,comparelevel) == 2 \
&& !$ignorekey} {
return 0
}
# Same size and time is always considered equal
if {$size1 == $size2 && $mtime1 == $mtime2} {
return 1
}
# Don't check further if contents should not be checked
if {$::Pref(dir,comparelevel) == 0} {
return 0
}
# Don't check further if any is a directory
|
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
|
$tree cellconfigure $topIndex,structure -text $d1
} else {
$tree cellconfigure $topIndex,structure -text "$d1 vs $d2"
}
$tree cellconfigure $topIndex,structure -image $::img(open)
$tree rowattrib $topIndex type directory
$self SetNodeStatus $topIndex empty
$tree rowattrib $topIndex leftfull $leftDir
$tree rowattrib $topIndex rightfull $rightDir
$self UpdateDirNode $topIndex
}
method expandCmd {tbl row} {
if {[$tree childcount $row] != 0} {
$tree cellconfigure $row,0 -image $::img(open)
|
|
>
|
>
|
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
|
$tree cellconfigure $topIndex,structure -text $d1
} else {
$tree cellconfigure $topIndex,structure -text "$d1 vs $d2"
}
$tree cellconfigure $topIndex,structure -image $::img(open)
$tree rowattrib $topIndex type directory
$self SetNodeStatus $topIndex empty
$tree rowattrib $topIndex leftfull $leftDir
$tree rowattrib $topIndex leftdict [dict create full $leftDir dir 1]
$tree rowattrib $topIndex rightfull $rightDir
$tree rowattrib $topIndex rightdict [dict create full $rightDir dir 1]
$self UpdateDirNode $topIndex
}
method expandCmd {tbl row} {
if {[$tree childcount $row] != 0} {
$tree cellconfigure $row,0 -image $::img(open)
|
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
|
set leftfull [$tree rowattrib $node leftfull]
set rightfull [$tree rowattrib $node rightfull]
$self CompareDirs $leftfull $rightfull $node
}
method UpdateFileNode {node} {
set leftfull [$tree rowattrib $node leftfull]
set rightfull [$tree rowattrib $node rightfull]
set equal [CompareFiles $leftfull $rightfull]
if {$equal} {
$self SetNodeStatus $node equal
} else {
$self SetNodeStatus $node change
}
}
|
|
|
|
|
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
|
set leftfull [$tree rowattrib $node leftfull]
set rightfull [$tree rowattrib $node rightfull]
$self CompareDirs $leftfull $rightfull $node
}
method UpdateFileNode {node} {
set leftdict [$tree rowattrib $node leftdict]
set rightdict [$tree rowattrib $node rightdict]
set equal [CompareFiles $leftdict $rightdict]
if {$equal} {
$self SetNodeStatus $node equal
} else {
$self SetNodeStatus $node change
}
}
|
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
|
"" \
$size2 $time2]
}
set id [$tree insertchild $node end $values]
$tree rowattrib $id type $type
$tree rowattrib $id status unknown
$tree rowattrib $id leftfull $df1
$tree rowattrib $id rightfull $df2
if {$type ne "directory"} {
if {$type eq "link"} {
$tree cellconfigure $id,structure -image $::img(link)
} else {
$tree cellconfigure $id,structure -image $::img(file)
$tree cellconfigure $id,command -window [mymethod addCmdCol]
}
|
>
>
|
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
|
"" \
$size2 $time2]
}
set id [$tree insertchild $node end $values]
$tree rowattrib $id type $type
$tree rowattrib $id status unknown
$tree rowattrib $id leftfull $df1
$tree rowattrib $id leftdict $fD1
$tree rowattrib $id rightfull $df2
$tree rowattrib $id rightdict $fD2
if {$type ne "directory"} {
if {$type eq "link"} {
$tree cellconfigure $id,structure -image $::img(link)
} else {
$tree cellconfigure $id,structure -image $::img(file)
$tree cellconfigure $id,command -window [mymethod addCmdCol]
}
|