2005-01-30 15:57:25 -05:00
|
|
|
! Copyright (C) 2003, 2005 Slava Pestov.
|
2006-01-17 02:43:38 -05:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
2005-06-19 17:50:35 -04:00
|
|
|
IN: io
|
2005-11-29 23:49:59 -05:00
|
|
|
USING: errors hashtables generic kernel math namespaces
|
|
|
|
sequences strings ;
|
2005-04-22 20:09:46 -04:00
|
|
|
|
2005-12-16 21:12:35 -05:00
|
|
|
GENERIC: stream-close ( stream -- )
|
|
|
|
GENERIC: set-timeout ( timeout stream -- )
|
2005-07-21 21:43:37 -04:00
|
|
|
GENERIC: stream-readln ( stream -- string )
|
|
|
|
GENERIC: stream-read1 ( stream -- char/f )
|
|
|
|
GENERIC: stream-read ( count stream -- string )
|
2005-12-16 21:12:35 -05:00
|
|
|
GENERIC: stream-write1 ( char stream -- )
|
|
|
|
GENERIC: stream-write ( string stream -- )
|
|
|
|
GENERIC: stream-flush ( stream -- )
|
|
|
|
GENERIC: stream-terpri ( stream -- )
|
|
|
|
GENERIC: stream-format ( string style stream -- )
|
2005-12-16 22:24:39 -05:00
|
|
|
GENERIC: with-nested-stream ( quot style stream -- )
|
2005-07-21 21:05:17 -04:00
|
|
|
|
2005-02-14 22:15:02 -05:00
|
|
|
: stream-print ( string stream -- )
|
2005-07-21 23:36:40 -04:00
|
|
|
[ stream-write ] keep stream-terpri ;
|
2004-12-15 16:57:29 -05:00
|
|
|
|
2005-06-19 18:31:02 -04:00
|
|
|
: (stream-copy) ( in out -- )
|
2005-07-21 21:43:37 -04:00
|
|
|
4096 pick stream-read
|
2005-09-24 15:21:17 -04:00
|
|
|
[ over stream-write (stream-copy) ] [ 2drop ] if* ;
|
2005-06-19 18:31:02 -04:00
|
|
|
|
|
|
|
: stream-copy ( in out -- )
|
2005-09-20 20:18:01 -04:00
|
|
|
[ 2dup (stream-copy) ] [ stream-close stream-close ] cleanup ;
|