--- a/AbstractFileBrowser.st Fri Jan 10 14:21:44 2003 +0100
+++ b/AbstractFileBrowser.st Fri Jan 10 14:23:17 2003 +0100
@@ -1897,6 +1897,69 @@
self fileApplicationDo:#openTerminalApplication: withArg:item.
!
+doCompareTwoFiles
+ |files fileName1 fileName2 stream1 stream2 buffer1 buffer2 n1 n2 idx blockSize blockOffset|
+
+ files := self currentFileNameHolder value.
+ fileName1 := files first.
+ fileName2 := files second.
+
+ (fileName1 exists and:[fileName1 isReadable]) ifFalse:[
+ Dialog warn:(resources string:'Cannot read %1' with:fileName1 pathName allBold).
+ ^ self.
+ ].
+ (fileName2 exists and:[fileName2 isReadable]) ifFalse:[
+ Dialog warn:(resources string:'Cannot read %1' with:fileName2 pathName allBold).
+ ^ self.
+ ].
+ [
+ stream1 := fileName1 readStream.
+ stream2 := fileName2 readStream.
+
+ stream1 binary. stream2 binary.
+
+ blockSize := 8192.
+ buffer1 := ByteArray new:blockSize.
+ buffer2 := ByteArray new:blockSize.
+
+ blockOffset := 0.
+
+ [stream1 atEnd] whileFalse:[
+ n1 := stream1 nextBytes:(buffer1 size) into:buffer1 startingAt:1.
+ n2 := stream2 nextBytes:n1 into:buffer2 startingAt:1.
+
+ n1 ~~ n2 ifTrue:[
+self halt.
+ ] ifFalse:[
+ buffer1 ~= buffer2 ifTrue:[
+ idx := (1 to:n1) findFirst:[:idx | (buffer1 at:idx) ~~ (buffer2 at:idx)].
+ Dialog information:(resources
+ string:'Files differ at position %1 (0x%2 vs. 0x%3)'
+ with:(blockOffset+idx)
+ with:((buffer1 at:idx) hexPrintString:2)
+ with:((buffer2 at:idx) hexPrintString:2)
+ ).
+ ^ self.
+ ]
+ ].
+ blockOffset := blockOffset + n1.
+ ].
+ stream2 atEnd ifFalse:[
+ self halt.
+ ].
+ ] ensure:[
+ stream1 notNil ifTrue:[stream1 close].
+ stream2 notNil ifTrue:[stream2 close].
+ ].
+
+self halt.
+"/ action := [:command |
+"/ self addToCommandHistory:command for:fileName.
+"/ self executeCommand:command.
+"/ ].
+"/ self askForCommandFor:fileName thenDo:action
+!
+
doExecuteCommand
| action fileName|
@@ -5454,5 +5517,5 @@
!AbstractFileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.78 2003-01-09 16:09:31 penk Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.79 2003-01-10 13:23:17 cg Exp $'
! !