Created
August 11, 2013 11:24
-
-
Save fomkin/6204438 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sys; | |
@:coreApi | |
class FileSystem { | |
public static function exists( path : String ) : Bool { | |
return new flash.filesystem.File(path).exists; | |
} | |
public static function rename( path : String, newpath : String ) : Void { | |
var newFile = new flash.filesystem.File(newpath); | |
var origFile = new flash.filesystem.File(path); | |
origFile.moveTo(newFile); | |
} | |
public static function stat( path : String ) : FileStat { | |
var file = new flash.filesystem.File(path); | |
var s = new FileStat(); | |
s.atime = Date.now(); | |
s.mtime = file.modificationDate; | |
s.ctime = file.creationDate; | |
return s; | |
} | |
public static function fullPath( relpath : String ) : String { | |
var file = new flash.filesystem.File(path); | |
return file.nativePath; | |
} | |
public static function isDirectory( path : String ) : Bool { | |
var file = new flash.filesystem.File(path); | |
return file.isDirectory; | |
} | |
public static function createDirectory( path : String ) : Void { | |
var file = new flash.filesystem.File(path); | |
file.createDirectory(); | |
} | |
public static function deleteFile( path : String ) : Void { | |
var file = new flash.filesystem.File(path); | |
file.deleteFile(); | |
} | |
public static function deleteDirectory( path : String ) : Void { | |
var file = new flash.filesystem.File(path); | |
file.deleteDirectory(); | |
} | |
public static function readDirectory( path : String ) : Array<String> { | |
var file = new flash.filesystem.File(path); | |
return Lambda.map(file.getDirectoryListing(), function(f) { return f.nativePath; } ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment