]> gitweb.factorcode.org Git - factor.git/blob - core/io/backend/backend.factor
Fix permission bits
[factor.git] / core / io / backend / backend.factor
1 ! Copyright (C) 2007, 2008 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 ;
5 IN: io.backend
6
7 SYMBOL: io-backend
8
9 SINGLETON: c-io-backend
10
11 c-io-backend io-backend set-global
12
13 HOOK: init-io io-backend ( -- )
14
15 HOOK: (init-stdio) io-backend ( -- stdin stdout stderr )
16
17 : init-stdio ( -- )
18     (init-stdio)
19     [ utf8 <decoder> input-stream set-global ]
20     [ utf8 <encoder> output-stream set-global ]
21     [ utf8 <encoder> error-stream set-global ] tri* ;
22
23 HOOK: io-multiplex io-backend ( ms -- )
24
25 HOOK: normalize-directory io-backend ( str -- newstr )
26
27 HOOK: normalize-path io-backend ( str -- newstr )
28
29 M: object normalize-directory normalize-path ;
30
31 : set-io-backend ( io-backend -- )
32     io-backend set-global init-io init-stdio
33     "io.files" init-hooks get at call ;
34
35 [ init-io embedded? [ init-stdio ] unless ]
36 "io.backend" add-init-hook