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 assocs splitting alien ;
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 ( us -- )
24 HOOK: normalize-directory io-backend ( path -- path' )
26 HOOK: normalize-path io-backend ( path -- path' )
28 M: object normalize-directory normalize-path ;
30 : set-io-backend ( io-backend -- )
31 io-backend set-global init-io init-stdio
32 "io.files" startup-hooks get at call( -- ) ;
34 ! Note that we have 'alien' in our using list so that the alien
35 ! init hook runs before this one.
36 [ init-io embedded? [ init-stdio ] unless ]
37 "io.backend" add-startup-hook