factor/core/io/backend/backend.factor

34 lines
933 B
Factor
Raw Normal View History

! Copyright (C) 2007, 2009 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
2013-03-05 13:34:47 -05:00
USING: assocs init io io.encodings io.encodings.utf8 kernel
namespaces system ;
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
io-backend [ c-io-backend ] initialize
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 ( -- )
: set-stdio ( input output error -- )
[ 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 ( nanos -- )
2007-09-20 18:09:08 -04:00
2009-10-17 01:09:57 -04:00
HOOK: normalize-path io-backend ( path -- path' )
2007-09-20 18:09:08 -04:00
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" startup-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-startup-hook