Browse Source

package neko.io

Nicolas Cannasse 19 years ago
parent
commit
8851863a45

+ 8 - 8
std/haxe/Http.hx

@@ -152,7 +152,7 @@ class Http {
 		}
 		// Bug in flash player 9 ???
 		var bug = small_url.split("xxx");
-		
+
 		var request = new flash.net.URLRequest( small_url );
 		for( k in headers.keys() ){
 			request.requestHeaders.push( new flash.net.URLRequestHeader(k,headers.get(k)) );
@@ -233,7 +233,7 @@ class Http {
 		if( request == "" )
 			request = "/";
 		var port = if( portString == "" ) 80 else Std.parseInt(portString.substr(1,portString.length-1));
-		var s = new neko.Socket();
+		var s = new neko.io.Socket();
 		var data;
 
 		var uri = null;
@@ -278,7 +278,7 @@ class Http {
 				b.add(uri);
 		}
 		try {
-			s.connect(neko.Socket.resolve(host),port);
+			s.connect(neko.io.Socket.resolve(host),port);
 			s.write(b.toString());
 			readHttpResponse(api,s);
 			s.close();
@@ -287,16 +287,16 @@ class Http {
 		}
 	}
 
-	function readHttpResponse( api : AsyncHttp, sock : neko.Socket ) {
+	function readHttpResponse( api : AsyncHttp, sock : neko.io.Socket ) {
 		// READ the HTTP header (until \r\n\r\n)
 		var b = new StringBuf();
 		var k = 4;
 		var s = neko.Lib.makeString(4);
 		sock.setTimeout(10); // 10 seconds
 		while( true ) {
-			var p = sock.receive(s,0,k);
+			var p = sock.input.read(s,0,k);
 			while( p != k )
-				p += sock.receive(s,p,k - p);
+				p += sock.input.read(s,p,k - p);
 			b.addSub(s,0,k);
 			switch( k ) {
 			case 1:
@@ -389,7 +389,7 @@ class Http {
 		if( size == null ) {
 			sock.shutdown(false,true);
 			while( true ) {
-				var len = sock.receive(buf,0,bufsize);
+				var len = sock.input.read(buf,0,bufsize);
 				if( len == 0 )
 					break;
 				if( chunked ) {
@@ -400,7 +400,7 @@ class Http {
 			}
 		} else {
 			while( size > 0 ) {
-				var len = sock.receive(buf,0,if( size > bufsize ) bufsize else size);
+				var len = sock.input.read(buf,0,if( size > bufsize ) bufsize else size);
 				if( len == 0 ) {
 					onError("Transfert aborted");
 					return;

+ 12 - 2
std/haxe/ImportAll.hx

@@ -488,16 +488,26 @@ import flash.text.TextRenderer;
 #if neko
 
 import neko.Boot;
-import neko.File;
 import neko.FileSystem;
 import neko.Lib;
 import neko.Random;
-import neko.Socket;
 import neko.Stack;
 import neko.Sys;
 import neko.Utf8;
 import neko.Web;
 
+import neko.io.Error;
+import neko.io.File;
+import neko.io.FileInput;
+import neko.io.FileOutput;
+import neko.io.Input;
+import neko.io.Output;
+import neko.io.Socket;
+import neko.io.SocketInput;
+import neko.io.SocketOutput;
+import neko.io.StringInput;
+import neko.io.StringOutput;
+
 import neko.zip.Compress;
 import neko.zip.File;
 import neko.zip.Flush;

+ 2 - 2
std/haxe/remoting/SocketBuffer.hx

@@ -38,7 +38,7 @@ class SocketBuffer {
 	var bufpos : Int;
 	var lastpos : Int;
 	var msglen : Int;
-	var sock : neko.Socket;
+	var sock : neko.io.Socket;
 	var lastread : Float;
 
 	public function new(s) {
@@ -65,7 +65,7 @@ class SocketBuffer {
 
 	public function read() {
 		var buflen = buffer.length;
-		var len = try sock.receive(buffer,bufpos,buflen-bufpos) catch( e : Dynamic ) { if( e == "Blocking" ) return; 0; };
+		var len = try sock.input.read(buffer,bufpos,buflen-bufpos) catch( e : Dynamic ) { if( e == neko.io.Error.Blocked ) return; 0; };
 		if( len == 0 )
 			throw ReadError;
 		lastread = neko.Sys.time();

+ 6 - 6
std/haxe/remoting/SocketConnection.hx

@@ -120,11 +120,11 @@ class SocketConnection extends AsyncConnection {
 			throw "Message is too big";
 		var c2 = encodeChar(len&63);
 		#if neko
-		var s : neko.Socket = __data;
-		s.sendChar(c1);
-		s.sendChar(c2);
-		s.write(msg);
-		s.sendChar(0);
+		var s : neko.io.Socket = __data;
+		s.output.writeChar(c1);
+		s.output.writeChar(c2);
+		s.output.writeBytes(msg);
+		s.output.writeChar(0);
 		#else flash
 		var s : flash.XMLSocket = __data;
 		s.send(Std.chr(c1)+Std.chr(c2)+msg);
@@ -197,7 +197,7 @@ class SocketConnection extends AsyncConnection {
 
 	#if neko
 
-	public static function socketConnect( s : neko.Socket, r : Server ) {
+	public static function socketConnect( s : neko.io.Socket, r : Server ) {
 		var sc = new SocketConnection(s,[]);
 		sc.__funs = new List();
 		sc.__r = r;

+ 0 - 140
std/neko/File.hx

@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2005, The haXe Project Contributors
- * All rights reserved.
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *   - Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- *   - Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- */
-package neko;
-
-/**
-	API for reading and writing to files.
-**/
-class File {
-
-	private var __f : Void;
-
-	private function new(f) {
-		__f = f;
-	}
-
-	public function name() : String {
-		return new String(file_name(__f));
-	}
-
-	public function read( nbytes : Int ) : String {
-		var s = untyped __dollar__smake(nbytes);
-		var p = 0;
-		while( nbytes > 0 ) {
-			var k = file_read(__f,s,p,nbytes);
-			if( k == 0 ) throw "Blocked";
-			p += k;
-			nbytes -= k;
-		}
-		return new String(s);
-	}
-
-	public function readBuf( s : String, p : Int, l : Int ) : Int {
-		return file_read(__f,untyped s.__s,p,l);
-	}
-
-	public function readChar() : Int {
-		return file_read_char(__f);
-	}
-
-	public function write( str : String ) {
-		var l = str.length;
-		var p = 0;
-		while( l > 0 ) {
-			var k = file_write(__f,untyped str.__s,p,l);
-			if( k == 0 ) throw "Blocked";
-			p += k;
-			l -= k;
-		}
-	}
-
-	public function writeSub( s : String, p : Int, l : Int ) : Int {
-		return file_write(__f,untyped s.__s,p,l);
-	}
-
-	public function writeChar( c : Int ) {
-		file_write_char(__f,c);
-	}
-
-	public function close() {
-		file_close(__f);
-	}
-
-	public function seekBegin( p : Int ) : Int {
-		return file_seek(__f,p,0);
-	}
-
-	public function seekEnd( p : Int ) : Int {
-		return file_seek(__f,p,2);
-	}
-
-	public function seek( p : Int ) : Int {
-		return file_seek(__f,p,1);
-	}
-
-	public function tell() : Int {
-		return file_tell(__f);
-	}
-
-	public function eof() : Bool {
-		return file_eof(__f);
-	}
-
-	public function flush() {
-		file_flush(__f);
-	}
-
-	// --- Statics ----
-
-	public static function getContent( filename : String ) {
-		return new String(file_contents(untyped filename.__s));
-	}
-
-	public static function read( path : String, binary : Bool ) {
-		return new File(untyped file_open(path.__s,(if( binary ) "rb" else "r").__s));
-	}
-
-	public static function write( path : String, binary : Bool ) {
-		return new File(untyped file_open(path.__s,(if( binary ) "wb" else "w").__s));
-	}
-
-	public static function append( path : String, binary : Bool ) {
-		return new File(untyped file_open(path.__s,(if( binary ) "ab" else "a").__s));
-	}
-
-	private static var file_contents = Lib.load("std","file_contents",1);
-	private static var file_open = Lib.load("std","file_open",2);
-	private static var file_close = Lib.load("std","file_close",1);
-	private static var file_name = Lib.load("std","file_name",1);
-	private static var file_write = Lib.load("std","file_write",4);
-	private static var file_read = Lib.load("std","file_read",4);
-	private static var file_read_char = Lib.load("std","file_read_char",1);
-	private static var file_write_char = Lib.load("std","file_write_char",2);
-	private static var file_seek = Lib.load("std","file_seek",3);
-	private static var file_tell = Lib.load("std","file_tell",1);
-	private static var file_eof = Lib.load("std","file_eof",1);
-	private static var file_flush = Lib.load("std","file_flush",1);
-
-}

+ 0 - 15
std/neko/Sys.hx

@@ -98,18 +98,6 @@ class Sys {
 		return h;
 	}
 
-	public static function stdin() : File {
-		return untyped new File(file_stdin());
-	}
-
-	public static function stdout() : File {
-		return untyped new File(file_stdout());
-	}
-
-	public static function stderr() : File {
-		return untyped new File(file_stderr());
-	}
-
 	private static var get_env = Lib.load("std","get_env",1);
 	private static var put_env = Lib.load("std","put_env",2);
 	private static var _sleep = Lib.load("std","sys_sleep",1);
@@ -122,8 +110,5 @@ class Sys {
 	private static var sys_time = Lib.load("std","sys_time",0);
 	private static var sys_exe_path = Lib.load("std","sys_exe_path",0);
 	private static var sys_env = Lib.load("std","sys_env",0);
-	private static var file_stdin = Lib.load("std","file_stdin",0);
-	private static var file_stdout = Lib.load("std","file_stdout",0);
-	private static var file_stderr = Lib.load("std","file_stderr",0);
 
 }

+ 39 - 0
std/neko/io/Error.hx

@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko.io;
+
+/**
+	The possible IO errors that can occur
+**/
+enum Error {
+	/** The end of the Input has been reached **/
+	Eof;
+	/** The IO is set into nonblocking mode and some data cannot be read or written **/
+	Blocked;
+	/** An operation has occured while the Input or Output has already been closed **/
+	Closed;
+	/** Other errors **/
+	Custom( e : Dynamic );
+}

+ 76 - 0
std/neko/io/File.hx

@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko.io;
+
+enum FileHandle {
+}
+
+enum FileSeek {
+	SeekBegin;
+	SeekCur;
+	SeekEnd;
+}
+
+/**
+	API for reading and writing to files.
+**/
+class File {
+
+	public static function getContent( path : String ) {
+		return new String(file_contents(untyped path.__s));
+	}
+
+	public static function read( path : String, binary : Bool ) {
+		return new FileInput(untyped file_open(path.__s,(if( binary ) "rb" else "r").__s));
+	}
+
+	public static function write( path : String, binary : Bool ) {
+		return new FileOutput(untyped file_open(path.__s,(if( binary ) "wb" else "w").__s));
+	}
+
+	public static function append( path : String, binary : Bool ) {
+		return new FileOutput(untyped file_open(path.__s,(if( binary ) "ab" else "a").__s));
+	}
+
+	public static function stdin() {
+		return new FileInput(file_stdin());
+	}
+
+	public static function stdout() {
+		return new FileOutput(file_stdout());
+	}
+
+	public static function stderr() {
+		return new FileOutput(file_stderr());
+	}
+
+	private static var file_stdin = neko.Lib.load("std","file_stdin",0);
+	private static var file_stdout = neko.Lib.load("std","file_stdout",0);
+	private static var file_stderr = neko.Lib.load("std","file_stderr",0);
+
+	private static var file_contents = neko.Lib.load("std","file_contents",1);
+	private static var file_open = neko.Lib.load("std","file_open",2);
+
+}

+ 86 - 0
std/neko/io/FileInput.hx

@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko.io;
+import neko.io.File;
+
+/**
+	Use [neko.io.File.read] to create a [FileInput]
+**/
+class FileInput extends Input {
+
+	private var __f : FileHandle;
+
+	public function new(f) {
+		__f = f;
+	}
+
+	public override function readChar() : Int {
+		return try {
+			file_read_char(__f);
+		} catch( e : Dynamic ) {
+			if( untyped __dollar__typeof(e) == __dollar__tarray )
+				throw Error.Eof;
+			else
+				throw Error.Custom(e);
+		}
+	}
+
+	public override function read( s : String, p : Int, l : Int ) : Int {
+		return try {
+			file_read(__f,untyped s.__s,p,l);
+		} catch( e : Dynamic ) {
+			if( untyped __dollar__typeof(e) == __dollar__tarray )
+				throw Error.Eof;
+			else
+				throw Error.Custom(e);
+		}
+	}
+
+	public override function close() {
+		super.close();
+		file_close(__f);
+	}
+
+	public function seek( p : Int, pos : FileSeek ) : Int {
+		return file_seek(__f,p,switch( pos ) { case SeekBegin: 0; case SeekCur: 1; case SeekEnd: 2; });
+	}
+
+	public function tell() : Int {
+		return file_tell(__f);
+	}
+
+	public function eof() : Bool {
+		return file_eof(__f);
+	}
+
+	private static var file_read = neko.Lib.load("std","file_read",4);
+	private static var file_read_char = neko.Lib.load("std","file_read_char",1);
+
+	private static var file_close = neko.Lib.load("std","file_close",1);
+	private static var file_seek = neko.Lib.load("std","file_seek",3);
+	private static var file_tell = neko.Lib.load("std","file_tell",1);
+	private static var file_eof = neko.Lib.load("std","file_eof",1);
+
+}

+ 85 - 0
std/neko/io/FileOutput.hx

@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko.io;
+import neko.io.File;
+
+/**
+	Use [neko.io.File.write] to create a [FileOutput]
+**/
+class FileOutput extends Output {
+
+	private var __f : FileHandle;
+
+	public function new(f) {
+		__f = f;
+	}
+
+	public override function writeChar( c : Int ) {
+		try {
+			file_write_char(__f,c);
+		} catch( e : Dynamic ) {
+			throw Error.Custom(e);
+		}
+	}
+
+	public override function write( s : String, p : Int, l : Int ) : Int {
+		return try {
+			file_write(__f,untyped s.__s,p,l);
+		} catch( e : Dynamic ) {
+			throw Error.Custom(e);
+		}
+	}
+
+	public override function flush() {
+		file_flush(__f);
+	}
+
+	public override function close() {
+		super.close();
+		file_close(__f);
+	}
+
+	public function seek( p : Int, pos : FileSeek ) : Int {
+		return file_seek(__f,p,switch( pos ) { case SeekBegin: 0; case SeekCur: 1; case SeekEnd: 2; });
+	}
+
+	public function tell() : Int {
+		return file_tell(__f);
+	}
+
+	public function eof() : Bool {
+		return file_eof(__f);
+	}
+
+	private static var file_close = neko.Lib.load("std","file_close",1);
+	private static var file_seek = neko.Lib.load("std","file_seek",3);
+	private static var file_tell = neko.Lib.load("std","file_tell",1);
+	private static var file_eof = neko.Lib.load("std","file_eof",1);
+
+	private static var file_flush = neko.Lib.load("std","file_flush",1);
+	private static var file_write = neko.Lib.load("std","file_write",4);
+	private static var file_write_char = neko.Lib.load("std","file_write_char",2);
+
+}

+ 103 - 0
std/neko/io/Input.hx

@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko.io;
+
+/**
+	An Input is an abstract reader. A specific input implementation will only
+	have to override the [readChar] and maybe [read] and [close] methods. See
+	[File] and [StringInput] for two ways of creating an Input.
+**/
+class Input {
+
+	public function readChar() : Int {
+		return throw "Not implemented";
+	}
+
+	public function read( s : String, p : Int, len : Int ) : Int {
+		var k = len;
+		while( k > 0 ) {
+			var c = readChar();
+			untyped __dollar__sset(s.__s,p,c);
+			p += 1;
+			k -= 1;
+		}
+		return len;
+	}
+
+	public function close() {
+		read = function(_,_,_) { return throw Error.Closed; };
+		readChar = function() { return throw Error.Closed; };
+		close = function() { throw Error.Closed; };
+	}
+
+
+	/* ------------------ API ------------------ */
+
+	public function readAll( ?bufsize : Int ) : String {
+		if( bufsize == null )
+			bufsize = (1 << 14); // 16 Ko
+		var buf = neko.Lib.makeString(bufsize);
+		var total = new StringBuf();
+		try {
+			while( true ) {
+				var len = read(buf,0,bufsize);
+				if( len == 0 )
+					throw Error.Blocked;
+				total.addSub(buf,0,len);
+			}
+		} catch( e : Error ) {
+			if( e != Error.Eof )
+				neko.Lib.rethrow(e);
+		}
+		return total.toString();
+	}
+
+	public function readBytes( nbytes : Int ) : String {
+		var s = neko.Lib.makeString(nbytes);
+		var p = 0;
+		while( nbytes > 0 ) {
+			var k = read(s,p,nbytes);
+			if( k == 0 ) throw Error.Blocked;
+			p += k;
+			nbytes -= k;
+		}
+		return s;
+	}
+
+	public function readUntil( end : Int ) : String {
+		var buf = new StringBuf();
+		var last : Int;
+		while( (last = readChar()) != end )
+			buf.addChar( last );
+		return buf.toString();
+	}
+
+	public function readLine() : String {
+		var s = readUntil( 10 );
+		if( s.substr(-1,1) == "\r" ) return s.substr(0,-1);
+		return s;
+	}
+
+}

+ 71 - 0
std/neko/io/Output.hx

@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko.io;
+
+/**
+	An Output is an abstract write. A specific output implementation will only
+	have to override the [writeChar] and maybe the [write], [flush] and [close]
+	methods. See [File.write] and [String.write] for two ways of creating an
+	Output.
+**/
+class Output {
+
+	public function writeChar( c : Int ) : Void {
+		throw "Not implemented";
+	}
+
+	public function write( s : String, p : Int, len : Int ) : Int {
+		var k = len;
+		while( k > 0 ) {
+			writeChar(untyped __dollar__sget(s.__s,p));
+			p += 1;
+			k -= 1;
+		}
+		return len;
+	}
+
+	public function flush() {
+	}
+
+	public function close() {
+		write = function(_,_,_) { return throw Error.Closed; };
+		writeChar = function(_) { throw Error.Closed; };
+		flush = close = function() { throw Error.Closed; };
+	}
+
+	/* ------------------ API ------------------ */
+
+	public function writeBytes( s : String ) : Void {
+		var l = s.length;
+		var p = 0;
+		while( l > 0 ) {
+			var k = write(s,p,l);
+			if( k == 0 ) throw Error.Blocked;
+			p += k;
+			l -= k;
+		}
+	}
+
+}

+ 40 - 69
std/neko/Socket.hx → std/neko/io/Socket.hx

@@ -1,3 +1,4 @@
+
 /*
  * Copyright (c) 2005, The haXe Project Contributors
  * All rights reserved.
@@ -24,56 +25,44 @@
  *
  * Contributor: Lee McColl Sylvester
  */
-package neko;
+package neko.io;
+
+enum SocketHandle {
+}
 
 enum Host {
 }
 
 class Socket {
 
-	private var __s : Void;
+	private var __s : SocketHandle;
+	public var input(default,null) : SocketInput;
+	public var output(default,null) : SocketOutput;
 
 	public function new() {
 		__s = socket_new(false);
+		input = new SocketInput(__s);
+		output = new SocketOutput(__s);
 	}
 
 	public function close() : Void {
 		socket_close(__s);
+		untyped {
+			input.__s = null;
+			output.__s = null;
+		}
+		input.close();
+		output.close();
 	}
 
-	public function sendChar(chr : Int) : Void {
-		socket_send_char(__s, chr);
-	}
-
-	public function send(buffer : String, pos : Int, len : Int) : Int {
-		return socket_send(__s, untyped buffer.__s, pos, len);
-	}
-
-	public function receive(buffer : String, pos : Int, len : Int) : Int {
-		return socket_recv(__s, untyped buffer.__s, pos, len);
-	}
-
-	public function receiveChar() : Int {
-		return socket_recv_char(__s);
+	public function read() : String {
+		return socket_read(__s);
 	}
 
-	public function write(content : String) {
+	public function write( content : String ) {
 		socket_write(__s, untyped content.__s);
 	}
 
-	public function read( ?nbytes : Int ) : String	{
-		if( nbytes == null )
-			return new String(socket_read(__s));
-		var s = Lib.makeString(nbytes);
-		var p = 0;
-		while( nbytes > 0 ) {
-			var l = receive(s,p,nbytes);
-			p += l;
-			nbytes -= l;
-		}
-		return s;
-	}
-
 	public function connect(host : Host, port : Int) {
 		socket_connect(__s, host, port);
 	}
@@ -116,20 +105,6 @@ class Socket {
 		select([this],null,null,null);
 	}
 
-	public function readUntil( end : Int ) : String {
-		var buf = new StringBuf();
-		var last : Int;
-		while( (last = socket_recv_char(__s)) != end )
-			buf.addChar( last );
-		return buf.toString();
-	}
-
-	public function readLine() : String {
-		var s = readUntil( 10 );
-		if( s.substr(-1,1) == "\r" ) return s.substr(0,-1);
-		return s;
-	}
-
 	public function setBlocking( b : Bool ) {
 		socket_set_blocking(__s,b);
 	}
@@ -190,30 +165,26 @@ class Socket {
 	}
 
 	static function __init__() {
-		Lib.load("std","socket_init",0)();
-	}
-
-	private static var socket_new = Lib.load("std","socket_new",1);
-	private static var socket_close = Lib.load("std","socket_close",1);
-	private static var socket_send_char = Lib.load("std","socket_send_char",2);
-	private static var socket_send = Lib.load("std","socket_send",4);
-	private static var socket_recv = Lib.load("std","socket_recv",4);
-	private static var socket_recv_char = Lib.load("std","socket_recv_char",1);
-	private static var socket_write = Lib.load("std","socket_write",2);
-	private static var socket_read = Lib.load("std","socket_read",1);
-	private static var host_resolve = Lib.load("std","host_resolve",1);
-	private static var host_reverse = Lib.load("std","host_reverse",1);
-	private static var host_to_string = Lib.load("std","host_to_string",1);
-	private static var host_local = Lib.load("std","host_local",0);
-	private static var socket_connect = Lib.load("std","socket_connect",3);
-	private static var socket_listen = Lib.load("std","socket_listen",2);
-	private static var socket_select = Lib.load("std","socket_select",4);
-	private static var socket_bind = Lib.load("std","socket_bind",3);
-	private static var socket_accept = Lib.load("std","socket_accept",1);
-	private static var socket_peer = Lib.load("std","socket_peer",1);
-	private static var socket_host = Lib.load("std","socket_host",1);
-	private static var socket_set_timeout = Lib.load("std","socket_set_timeout",2);
-	private static var socket_shutdown = Lib.load("std","socket_shutdown",3);
-	private static var socket_set_blocking = Lib.load("std","socket_set_blocking",2);
+		neko.Lib.load("std","socket_init",0)();
+	}
+
+	private static var socket_new = neko.Lib.load("std","socket_new",1);
+	private static var socket_close = neko.Lib.load("std","socket_close",1);
+	private static var socket_write = neko.Lib.load("std","socket_write",2);
+	private static var socket_read = neko.Lib.load("std","socket_read",1);
+	private static var host_resolve = neko.Lib.load("std","host_resolve",1);
+	private static var host_reverse = neko.Lib.load("std","host_reverse",1);
+	private static var host_to_string = neko.Lib.load("std","host_to_string",1);
+	private static var host_local = neko.Lib.load("std","host_local",0);
+	private static var socket_connect = neko.Lib.load("std","socket_connect",3);
+	private static var socket_listen = neko.Lib.load("std","socket_listen",2);
+	private static var socket_select = neko.Lib.load("std","socket_select",4);
+	private static var socket_bind = neko.Lib.load("std","socket_bind",3);
+	private static var socket_accept = neko.Lib.load("std","socket_accept",1);
+	private static var socket_peer = neko.Lib.load("std","socket_peer",1);
+	private static var socket_host = neko.Lib.load("std","socket_host",1);
+	private static var socket_set_timeout = neko.Lib.load("std","socket_set_timeout",2);
+	private static var socket_shutdown = neko.Lib.load("std","socket_shutdown",3);
+	private static var socket_set_blocking = neko.Lib.load("std","socket_set_blocking",2);
 
 }

+ 67 - 0
std/neko/io/SocketInput.hx

@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko.io;
+import neko.io.Socket;
+
+class SocketInput extends Input {
+
+	var __s : SocketHandle;
+
+	public function new(s) {
+		__s = s;
+	}
+
+	public override function readChar() {
+		return try {
+			socket_recv_char(__s);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Error.Blocked;
+			else
+				throw Error.Eof; // might also be closed socket
+		}
+	}
+
+	public override function read( buf : String, pos : Int, len : Int ) : Int {
+		return try {
+			socket_recv(__s,untyped buf.__s,pos,len);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Error.Blocked;
+			else
+				throw Error.Eof; // might also be closed socket or invalid param...
+		}
+	}
+
+	public override function close() {
+		super.close();
+		if( __s != null ) socket_close(__s);
+	}
+
+	private static var socket_recv = neko.Lib.load("std","socket_recv",4);
+	private static var socket_recv_char = neko.Lib.load("std","socket_recv_char",1);
+	private static var socket_close = neko.Lib.load("std","socket_close",1);
+
+}

+ 67 - 0
std/neko/io/SocketOutput.hx

@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko.io;
+import neko.io.Socket;
+
+class SocketOutput extends Output {
+
+	var __s : SocketHandle;
+
+	public function new(s) {
+		__s = s;
+	}
+
+	public override function writeChar( c : Int ) {
+		try {
+			socket_send_char(__s, c);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Error.Blocked;
+			else
+				throw Error.Custom(e);
+		}
+	}
+
+	public override function write( buf : String, pos : Int, len : Int) : Int {
+		return try {
+			socket_send(__s, untyped buffer.__s, pos, len);
+		} catch( e : Dynamic ) {
+			if( e == "Blocking" )
+				throw Error.Blocked;
+			else
+				throw Error.Custom(e);
+		}
+	}
+
+	public override function close() {
+		super.close();
+		if( __s != null ) socket_close(__s);
+	}
+
+	private static var socket_close = neko.Lib.load("std","socket_close",1);
+	private static var socket_send_char = neko.Lib.load("std","socket_send_char",2);
+	private static var socket_send = neko.Lib.load("std","socket_send",4);
+
+}

+ 59 - 0
std/neko/io/StringInput.hx

@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko.io;
+
+class StringInput extends Input {
+
+	var s : String;
+	var pos : Int;
+	var len : Int;
+
+	public function new( s : String, ?pos : Int, ?len : Int ) {
+		this.s = s;
+		this.pos = if( pos == null ) 0 else pos;
+		this.len = if( len == null ) s.length else len;
+		if( this.pos < 0 || this.len < 0 )
+			throw "Invalid parameter";
+	}
+
+	public override function readChar() {
+		if( this.len == 0 )
+			throw Error.Eof;
+		var c = untyped __dollar__sget(s.__s,pos);
+		pos += 1;
+		len -= 1;
+		return c;
+	}
+
+	public override function read( buf : String, bpos, blen ) : Int {
+		if( len <= blen )
+			blen = len;
+		untyped __dollar__sblit(buf.__s,bpos,s.__s,pos,blen);
+		pos += blen;
+		len -= blen;
+		return blen;
+	}
+
+}

+ 48 - 0
std/neko/io/StringOutput.hx

@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2005, The haXe Project Contributors
+ * All rights reserved.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *   - Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   - Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package neko.io;
+
+class StringOutput extends Output {
+
+	var b : StringBuf;
+
+	public function new() {
+		b = new StringBuf();
+	}
+
+	public override function writeChar(c) {
+		b.addChar(c);
+	}
+
+	public override function write( buf, bpos, blen ) : Int {
+		b.addSub(buf,bpos,blen);
+		return blen;
+	}
+
+	public function toString() {
+		return b.toString();
+	}
+
+}

+ 5 - 5
std/tools/haxedoc/Main.hx

@@ -574,7 +574,7 @@ class DocView {
 	}
 
 	static function loadFile(file) {
-		var data = neko.File.getContent(Web.getCwd()+file);
+		var data = neko.io.File.getContent(Web.getCwd()+file);
 		var x = Xml.parse(data).firstChild();
 		for( c in x.elements() )
 			processClass(c);
@@ -635,8 +635,8 @@ class DocView {
 	static function save(html,clname,file) {
 		Url.buffer = new StringBuf();
 		displayHtml(html,clname);
-		var f = neko.File.write(file,false);
-		f.write(Url.buffer.toString());
+		var f = neko.io.File.write(file,false);
+		f.writeBytes(Url.buffer.toString());
 		f.close();
 		neko.Lib.print(".");
 	}
@@ -675,11 +675,11 @@ class DocView {
 	public static function main() {
 		var hdata =
 			try
-				neko.File.getContent(Web.getCwd()+"template.xml")
+				neko.io.File.getContent(Web.getCwd()+"template.xml")
 			catch( e : Dynamic ) try {
 				var p = ~/[\/\\]/g.split(neko.Sys.executablePath());
 				p.pop();
-				neko.File.getContent(p.join("/")+"/std/tools/template.xml");
+				neko.io.File.getContent(p.join("/")+"/std/tools/template.xml");
 			} catch( e : Dynamic )
 				default_template;
 		var html = Xml.parse(hdata).firstChild();