--- a/FileBrowser.st Wed Nov 18 20:19:19 1998 +0100
+++ b/FileBrowser.st Sat Nov 21 13:23:49 1998 +0100
@@ -1553,7 +1553,7 @@
files := entry asArray.
1 to:files size-1 do:[:idx1 |
idx1+1 to:files size do:[:idx2 |
- |fn1 fn2|
+ |fn1 fn2 s1 s2 b1 b2 n same|
fn1 := files at:idx1.
fn2 := files at:idx2.
@@ -1561,10 +1561,33 @@
(result at:fn2 ifAbsent:nil) ~= fn1 ifTrue:[
"/ compare the files
- (fn1 binaryContentsOfEntireFile = fn2 binaryContentsOfEntireFile) ifTrue:[
+ (fn1 fileSize < (512*1024)) ifTrue:[
+ (fn1 binaryContentsOfEntireFile = fn2 binaryContentsOfEntireFile) ifTrue:[
"/ Transcript show:'Same: '; show:fn1 baseName; show:' and '; showCR:fn2 baseName.
- result at:fn1 put:fn2.
- ]
+ result at:fn1 put:fn2.
+ ]
+ ] ifFalse:[
+ "/ compare blockwise ...
+ s1 := fn1 readStream binary.
+ s2 := fn2 readStream binary.
+ b1 := ByteArray new:8192.
+ b2 := ByteArray new:8192.
+ same := true.
+ [same and:[s1 atEnd not]] whileTrue:[
+ n := s1 nextBytes:8192 into:b1 startingAt:1.
+ s2 nextBytes:n into:b2 startingAt:1.
+ n == 8192 ifFalse:[
+ b1 from:n+1 to:8192 put:0.
+ b2 from:n+1 to:8192 put:0.
+ ].
+ same := (b1 = b2)
+ ].
+ s1 close.
+ s2 close.
+ same ifTrue:[
+ result at:fn1 put:fn2.
+ ]
+ ]
]
]
]
@@ -5896,5 +5919,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.273 1998-11-18 19:19:19 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.274 1998-11-21 12:23:49 cg Exp $'
! !