| 
									
										
										
										
											2009-01-27 01:03:34 -05:00
										 |  |  | ! Copyright (C) 2007, 2009 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 | 
					
						
							| 
									
										
										
										
											2009-05-14 23:31:29 -04:00
										 |  |  | io.encodings.utf8 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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-10 17:16:12 -05:00
										 |  |  | 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 ( -- )
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-12 04:35:48 -04:00
										 |  |  | 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-24 01:51:46 -05:00
										 |  |  | HOOK: io-multiplex io-backend ( us -- )
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-17 01:09:57 -04:00
										 |  |  | HOOK: normalize-directory io-backend ( path -- path' )
 | 
					
						
							| 
									
										
										
										
											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-04-01 20:51:49 -04:00
										 |  |  | M: object normalize-directory normalize-path ;
 | 
					
						
							| 
									
										
										
										
											2008-03-26 23:47:13 -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 | 
					
						
							| 
									
										
										
										
											2009-10-19 22:17:02 -04:00
										 |  |  |     "io.files" startup-hooks get at call( -- ) ;
 | 
					
						
							| 
									
										
										
										
											2008-02-18 06:07:40 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-12 20:48:17 -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 ] | 
					
						
							| 
									
										
										
										
											2009-10-19 22:17:02 -04:00
										 |  |  | "io.backend" add-startup-hook |