factor/core/checksums/checksums.factor

26 lines
698 B
Factor
Raw Normal View History

2008-04-30 17:11:55 -04:00
! Copyright (c) 2008 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
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 )
M: checksum checksum-bytes
[ binary <byte-reader> ] dip checksum-stream ;
M: checksum checksum-stream
[ stream-contents ] dip checksum-bytes ;
2008-04-30 17:11:55 -04: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 )
[ binary <file-reader> ] dip checksum-stream ;