1 ! Copyright (C) 2007, 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: assocs init io io.encodings io.encodings.utf8 kernel
9 SINGLETON: c-io-backend
11 io-backend [ c-io-backend ] initialize
13 HOOK: init-io io-backend ( -- )
15 HOOK: init-stdio io-backend ( -- )
17 : set-stdio ( input output error -- )
18 [ utf8 <decoder> input-stream set-global ]
19 [ utf8 <encoder> output-stream set-global ]
20 [ utf8 <encoder> error-stream set-global ] tri* ;
22 HOOK: io-multiplex io-backend ( nanos -- )
24 HOOK: normalize-path io-backend ( path -- path' )
26 : set-io-backend ( io-backend -- )
27 io-backend set-global init-io init-stdio
28 "io.files" startup-hooks get at call( -- ) ;
30 ! Note that we have 'alien' in our using list so that the alien
31 ! init hook runs before this one.
32 [ init-io embedded? [ init-stdio ] unless ]
33 "io.backend" add-startup-hook