factor/core/io/backend/backend.factor

33 lines
895 B
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 ;
2007-09-20 18:09:08 -04:00
IN: io.backend
SYMBOL: io-backend
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
HOOK: io-multiplex io-backend ( ms -- )
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
[ init-io embedded? [ init-stdio ] unless ]
"io.backend" add-init-hook