|
@@ -22,37 +22,51 @@
|
|
package sys.io;
|
|
package sys.io;
|
|
import lua.Lua;
|
|
import lua.Lua;
|
|
import lua.Io;
|
|
import lua.Io;
|
|
|
|
+import lua.Os;
|
|
|
|
+import lua.FileHandle;
|
|
|
|
|
|
@:coreApi
|
|
@:coreApi
|
|
class File {
|
|
class File {
|
|
- public static function getContent( path : String ) : String {
|
|
|
|
|
|
+ public static function getContent( path : String ) : String {
|
|
var f = Io.open(path, "r");
|
|
var f = Io.open(path, "r");
|
|
- var s = f.read("*all");
|
|
|
|
|
|
+ var s = f.read(All);
|
|
f.close();
|
|
f.close();
|
|
return s;
|
|
return s;
|
|
}
|
|
}
|
|
|
|
+
|
|
public static function append( path : String, binary : Bool = true ) : FileOutput {
|
|
public static function append( path : String, binary : Bool = true ) : FileOutput {
|
|
- // var s = getContent(path);
|
|
|
|
|
|
+ return new FileOutput(Io.open(path, "a"));
|
|
|
|
|
|
- return null;
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
public static function copy( srcPath : String, dstPath : String ) : Void {
|
|
public static function copy( srcPath : String, dstPath : String ) : Void {
|
|
-
|
|
|
|
|
|
+ Os.execute('copy $srcPath $dstPath');
|
|
}
|
|
}
|
|
|
|
|
|
public static function getBytes( path : String ) : haxe.io.Bytes {
|
|
public static function getBytes( path : String ) : haxe.io.Bytes {
|
|
- return null;
|
|
|
|
|
|
+ var f = read(path, true);
|
|
|
|
+ var ret = f.readAll();
|
|
|
|
+ f.close();
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
+
|
|
public static function read( path : String, binary : Bool = true ) : FileInput {
|
|
public static function read( path : String, binary : Bool = true ) : FileInput {
|
|
- return null;
|
|
|
|
|
|
+ return new FileInput(Io.open(path,'r'));
|
|
}
|
|
}
|
|
|
|
+
|
|
public static function write( path : String, binary : Bool = true ) : FileOutput {
|
|
public static function write( path : String, binary : Bool = true ) : FileOutput {
|
|
- return null;
|
|
|
|
|
|
+ return new FileOutput(Io.open(path,'w'));
|
|
}
|
|
}
|
|
|
|
+
|
|
public static function saveBytes( path : String, bytes : haxe.io.Bytes ) : Void {
|
|
public static function saveBytes( path : String, bytes : haxe.io.Bytes ) : Void {
|
|
-
|
|
|
|
|
|
+ var f = write(path, true);
|
|
|
|
+ f.writeBytes(bytes, 0, bytes.length);
|
|
|
|
+ f.close();
|
|
}
|
|
}
|
|
|
|
|
|
public static function saveContent( path : String, content : String ) : Void {
|
|
public static function saveContent( path : String, content : String ) : Void {
|
|
|
|
+ var f = write(path, false);
|
|
|
|
+ f.writeString(content);
|
|
|
|
+ f.close();
|
|
}
|
|
}
|
|
}
|
|
}
|