]> gitweb.factorcode.org Git - factor.git/blob - core/io/backend/backend.factor
change add-init-hook to add-startup-hook, new add-shutdown-hook word
[factor.git] / core / io / backend / backend.factor
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 ;
5 IN: io.backend
6
7 SYMBOL: io-backend
8
9 SINGLETON: c-io-backend
10
11 io-backend [ c-io-backend ] initialize
12
13 HOOK: init-io io-backend ( -- )
14
15 HOOK: init-stdio io-backend ( -- )
16
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* ;
21
22 HOOK: io-multiplex io-backend ( us -- )
23
24 HOOK: normalize-directory io-backend ( path -- path' )
25
26 HOOK: normalize-path io-backend ( path -- path' )
27
28 M: object normalize-directory normalize-path ;
29
30 : set-io-backend ( io-backend -- )
31     io-backend set-global init-io init-stdio
32     "io.files" startup-hooks get at call( -- ) ;
33
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