Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Use file dictinoary down to CompareFiles |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
42caa7a2a85f016f68b163a21aa35dba |
User & Date: | peter 2014-07-21 00:37:54.256 |
Context
2014-10-27
| ||
15:40 | Store default prefs as comment in rc file check-in: 32d8697a40 user: peter tags: trunk | |
2014-07-21
| ||
00:37 | Use file dictinoary down to CompareFiles check-in: 42caa7a2a8 user: peter tags: trunk | |
00:17 | Use dicts down to ListFiles method. check-in: e1a6e25443 user: peter tags: trunk | |
Changes
Changes to src/dirdiff.tcl.
︙ | ︙ | |||
43 44 45 46 47 48 49 | return -1 } return 1 } # Compare two files or dirs # Return true if equal | | | | > > > > > > > > | | | > > > > | | | | 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 | $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 | | > | > | 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 | set leftfull [$tree rowattrib $node leftfull] set rightfull [$tree rowattrib $node rightfull] $self CompareDirs $leftfull $rightfull $node } method UpdateFileNode {node} { | | | | | 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] } |
︙ | ︙ |