factor/core/io/backend/backend.factor

39 lines
1.0 KiB
Factor
Raw Normal View History

2008-01-23 03:07:15 -05:00
! Copyright (C) 2007, 2008 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
2008-03-27 18:12:39 -04:00
USING: init kernel system namespaces io io.encodings
io.encodings.utf8 init assocs splitting alien ;
2007-09-20 18:09:08 -04:00
IN: io.backend
SYMBOL: io-backend
2008-10-02 04:38:36 -04:00
SINGLETON: c-io-backend
2008-11-24 01:51:46 -05:00
io-backend global [ c-io-backend or ] change-at
2008-10-02 04:38:36 -04:00
2007-09-20 18:09:08 -04:00
HOOK: init-io io-backend ( -- )
HOOK: (init-stdio) io-backend ( -- stdin stdout stderr )
: init-stdio ( -- )
(init-stdio)
[ utf8 <decoder> input-stream set-global ]
[ utf8 <encoder> output-stream set-global ]
[ utf8 <encoder> error-stream set-global ] tri* ;
2007-09-20 18:09:08 -04:00
2008-11-24 01:51:46 -05:00
HOOK: io-multiplex io-backend ( us -- )
2007-09-20 18:09:08 -04:00
HOOK: normalize-directory io-backend ( str -- newstr )
HOOK: normalize-path io-backend ( str -- newstr )
2007-09-20 18:09:08 -04:00
M: object normalize-directory normalize-path ;
2008-02-24 20:58:34 -05:00
: set-io-backend ( io-backend -- )
2008-03-27 18:12:39 -04:00
io-backend set-global init-io init-stdio
"io.files" init-hooks get at call ;
2008-02-18 06:07:40 -05:00
! Note that we have 'alien' in our using list so that the alien
! init hook runs before this one.
2008-02-18 06:07:40 -05:00
[ init-io embedded? [ init-stdio ] unless ]
"io.backend" add-init-hook