2008-04-30 17:11:55 -04:00
|
|
|
! Copyright (c) 2008 Slava Pestov
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2016-06-30 14:41:27 -04:00
|
|
|
USING: io io.backend io.encodings.binary io.files
|
|
|
|
io.streams.byte-array kernel sequences ;
|
2008-04-30 17:11:55 -04:00
|
|
|
IN: checksums
|
|
|
|
|
|
|
|
MIXIN: checksum
|
|
|
|
|
|
|
|
GENERIC: checksum-bytes ( bytes checksum -- value )
|
|
|
|
|
|
|
|
GENERIC: checksum-stream ( stream checksum -- value )
|
|
|
|
|
|
|
|
GENERIC: checksum-lines ( lines checksum -- value )
|
|
|
|
|
2016-06-30 14:41:27 -04:00
|
|
|
M: checksum checksum-bytes
|
|
|
|
[ binary <byte-reader> ] dip checksum-stream ;
|
|
|
|
|
2008-11-23 03:44:56 -05:00
|
|
|
M: checksum checksum-stream
|
2009-05-01 11:41:27 -04:00
|
|
|
[ stream-contents ] dip checksum-bytes ;
|
2008-04-30 17:11:55 -04:00
|
|
|
|
2008-11-23 03:44:56 -05:00
|
|
|
M: checksum checksum-lines
|
|
|
|
[ B{ CHAR: \n } join ] dip checksum-bytes ;
|
2008-04-30 17:11:55 -04:00
|
|
|
|
2008-05-01 21:02:34 -04:00
|
|
|
: checksum-file ( path checksum -- value )
|
2016-06-30 14:41:27 -04:00
|
|
|
[ binary <file-reader> ] dip checksum-stream ;
|