1 ! Copyright (C) 2007, 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: init kernel system namespaces io io.encodings
4 io.encodings.utf8 init assocs splitting ;
9 SINGLETON: c-io-backend
11 c-io-backend io-backend set-global
13 HOOK: init-io io-backend ( -- )
15 HOOK: (init-stdio) io-backend ( -- stdin stdout stderr )
19 [ utf8 <decoder> input-stream set-global ]
20 [ utf8 <encoder> output-stream set-global ]
21 [ utf8 <encoder> error-stream set-global ] tri* ;
23 HOOK: io-multiplex io-backend ( ms -- )
25 HOOK: normalize-directory io-backend ( str -- newstr )
27 HOOK: normalize-path io-backend ( str -- newstr )
29 M: object normalize-directory normalize-path ;
31 : set-io-backend ( io-backend -- )
32 io-backend set-global init-io init-stdio
33 "io.files" init-hooks get at call ;
35 [ init-io embedded? [ init-stdio ] unless ]
36 "io.backend" add-init-hook