1 ! Copyright (C) 2007, 2009 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 alien io.streams.null ;
9 SINGLETON: c-io-backend
11 io-backend global [ c-io-backend or ] change-at
13 HOOK: init-io io-backend ( -- )
15 HOOK: (init-stdio) io-backend ( -- stdin stdout stderr ? )
17 : set-stdio ( input-handle output-handle error-handle -- )
18 [ input-stream set-global ]
19 [ output-stream set-global ]
20 [ error-stream set-global ] tri* ;
26 [ utf8 <encoder> ] tri*
29 null-reader null-writer null-writer
32 HOOK: io-multiplex io-backend ( us -- )
34 HOOK: normalize-directory io-backend ( str -- newstr )
36 HOOK: normalize-path io-backend ( str -- newstr )
38 M: object normalize-directory normalize-path ;
40 : set-io-backend ( io-backend -- )
41 io-backend set-global init-io init-stdio
42 "io.files" init-hooks get at call ;
44 ! Note that we have 'alien' in our using list so that the alien
45 ! init hook runs before this one.
46 [ init-io embedded? [ init-stdio ] unless ]
47 "io.backend" add-init-hook