AsyncFileSystem.hx 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package asys;
  2. import haxe.Error;
  3. import haxe.NoData;
  4. import haxe.async.Callback;
  5. import haxe.io.Bytes;
  6. import haxe.io.FilePath;
  7. import asys.*;
  8. /**
  9. This class provides methods for asynchronous operations on files and
  10. directories. For synchronous operations, see `asys.FileSystem`.
  11. All methods here are asynchronous versions of the functions in
  12. `asys.FileSystem`. Please see them for a description of the arguments and
  13. use of each method.
  14. Any synchronous method that returns no value (`Void` return type) has an
  15. extra `callback:Callback<NoData>` argument.
  16. Any synchronous method that returns a value has an extra
  17. `callback:Callback<T>` argument, where `T` is the return type of the
  18. synchronous method.
  19. Errors are communicated through the callbacks or in some cases thrown
  20. immediately.
  21. **/
  22. extern class AsyncFileSystem {
  23. static function access(path:FilePath, ?mode:FileAccessMode = FileAccessMode.Ok, callback:Callback<NoData>):Void;
  24. static function chmod(path:FilePath, mode:FilePermissions, ?followSymLinks:Bool = true, callback:Callback<NoData>):Void;
  25. static function chown(path:FilePath, uid:Int, gid:Int, ?followSymLinks:Bool = true, callback:Callback<NoData>):Void;
  26. //static function copyFile(src:FilePath, dest:FilePath, ?flags:FileCopyFlags, callback:Callback<NoData>):Void;
  27. static function exists(path:FilePath, callback:Callback<Bool>):Void;
  28. static function link(existingPath:FilePath, newPath:FilePath, callback:Callback<NoData>):Void;
  29. static function mkdir(path:FilePath, ?recursive:Bool, ?mode:FilePermissions, callback:Callback<NoData>):Void;
  30. static function mkdtemp(prefix:FilePath, callback:Callback<FilePath>):Void;
  31. static function readdir(path:FilePath, callback:Callback<Array<FilePath>>):Void;
  32. static function readdirTypes(path:FilePath, callback:Callback<Array<DirectoryEntry>>):Void;
  33. static function readlink(path:FilePath, callback:Callback<FilePath>):Void;
  34. static function realpath(path:FilePath, callback:Callback<FilePath>):Void;
  35. static function rename(oldPath:FilePath, newPath:FilePath, callback:Callback<NoData>):Void;
  36. static function rmdir(path:FilePath, callback:Callback<NoData>):Void;
  37. static function stat(path:FilePath, ?followSymLinks:Bool = true, callback:Callback<FileStat>):Void;
  38. static function symlink(target:FilePath, path:FilePath, ?type:String, callback:Callback<NoData>):Void;
  39. static function truncate(path:FilePath, len:Int, callback:Callback<NoData>):Void;
  40. static function unlink(path:FilePath, callback:Callback<NoData>):Void;
  41. static function utimes(path:FilePath, atime:Date, mtime:Date, callback:Callback<NoData>):Void;
  42. static function appendFile(path:FilePath, data:Bytes, ?flags:FileOpenFlags, ?mode:FilePermissions, callback:Callback<NoData>):Void;
  43. static function open(path:FilePath, ?flags:FileOpenFlags, ?mode:FilePermissions, ?binary:Bool = true, callback:Callback<sys.io.File>):Void;
  44. static function readFile(path:FilePath, ?flags:FileOpenFlags, callback:Callback<Bytes>):Void;
  45. static function writeFile(path:FilePath, data:Bytes, ?flags:FileOpenFlags, ?mode:FilePermissions, callback:Callback<NoData>):Void;
  46. }