Add stubs for AIR sys API support

This commit is contained in:
Joshua Granick
2018-07-10 12:27:15 -07:00
parent 8f543e8eff
commit 5aa71b1f8d
5 changed files with 304 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
package sys;
@:dce
@:coreApi
class FileSystem {
public static function exists (path:String):Bool {
return false;
}
public static function rename (path:String, newPath:String):Void {
}
public static function stat (path:String):sys.FileStat {
return null;
}
public static function fullPath (relPath:String):String {
return null;
}
public static function absolutePath (relPath:String):String {
return null;
}
public static function isDirectory (path:String):Bool {
return false;
}
public static function createDirectory (path:String):Void {
}
public static function deleteFile (path:String):Void {
}
public static function deleteDirectory (path:String):Void {
}
public static function readDirectory (path:String):Array<String> {
}
}

View File

@@ -0,0 +1,82 @@
package sys.io;
import flash.filesystem.File in FlashFile;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
@:dce
@:coreApi
class File {
public static function getContent (path:String):String {
var file = new FlashFile (path);
var stream = new FileStream ();
stream.open (file, FileMode.READ);
var content = stream.readUTFBytes (stream.bytesAvailable);
stream.close ();
return content;
}
public static function saveContent (path:String, content:String):Void {
}
public static function getBytes (path:String):haxe.io.Bytes {
return null;
}
public static function saveBytes (path:String, bytes:haxe.io.Bytes):Void {
}
public static function read (path:String, binary:Bool = true):FileInput {
return null;
}
public static function write (path:String, binary:Bool = true):FileOutput {
return null;
}
public static function append (path:String, binary:Bool = true):FileOutput {
return null;
}
public static function update (path:String, binary:Bool = true):FileOutput {
return null;
}
public static function copy (srcPath:String, dstPath:String):Void {
}
}

View File

@@ -0,0 +1,75 @@
package sys.io;
import haxe.io.Bytes;
import haxe.io.Eof;
import haxe.io.Error;
@:coreApi
class FileInput extends haxe.io.Input {
private var fd:Int;
private var pos:Int;
@:allow(sys.io.File)
private function new (fd:Int) {
this.fd = fd;
pos = 0;
}
override public function readByte ():Int {
return 0;
}
override public function readBytes (s:Bytes, pos:Int, len:Int):Int {
return 0;
}
override public function close ():Void {
}
public function seek (p:Int, pos:FileSeek):Void {
switch (pos) {
case SeekBegin:
// this.pos = p;
case SeekEnd:
// this.pos = cast Fs.fstatSync(fd).size + p;
case SeekCur:
// this.pos += p;
}
}
public function tell ():Int {
return 0;
}
public function eof ():Bool {
return false;
}
}

View File

@@ -0,0 +1,68 @@
package sys.io;
import haxe.io.Bytes;
import haxe.io.Eof;
import haxe.io.Error;
@:coreApi
class FileOutput extends haxe.io.Output {
private var fd:Int;
private var pos:Int;
@:allow(sys.io.File)
private function new (fd:Int) {
this.fd = fd;
pos = 0;
}
override public function writeByte (b:Int):Void {
}
override public function writeBytes (s:Bytes, pos:Int, len:Int):Int {
return 0;
}
override public function close ():Void {
}
public function seek (p:Int, pos:FileSeek):Void {
switch (pos) {
case SeekBegin:
// this.pos = p;
case SeekEnd:
// this.pos = cast Fs.fstatSync(fd).size + p;
case SeekCur:
// this.pos += p;
}
}
public function tell ():Int {
return 0;
}
}