2
0
Nicolas Cannasse 17 жил өмнө
parent
commit
1d4215f632

+ 10 - 0
std/haxe/io/Bytes.hx

@@ -222,4 +222,14 @@ class Bytes {
 		#end
 	}
 
+	public static function ofData( b : BytesData ) {
+		#if flash9
+		return new Bytes(b.length,b);
+		#elseif neko
+		return new Bytes(untyped __dollar__ssize(b),b);
+		#else
+		return new Bytes(b.length,b);
+		#end
+	}
+
 }

+ 2 - 1
std/haxe/io/BytesBuffer.hx

@@ -92,7 +92,8 @@ class BytesBuffer {
 		var str = StringBuf.__string(b);
 		var bytes =  new Bytes(__dollar__ssize(str),str);
 		#elseif flash9
-		var bytes = new Bytes(b.position,b);
+		var bytes = new Bytes(b.length,b);
+		b.position = 0;
 		#else
 		var bytes = new Bytes(b.length,b);
 		#end