FileSystem.hx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (C)2005-2012 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package sys;
  23. /**
  24. This class allows you to get informations about the files and directories.
  25. **/
  26. extern class FileSystem {
  27. /**
  28. Tells if the given file or directory exists.
  29. **/
  30. static function exists( path : String ) : Bool;
  31. /**
  32. Rename the corresponding file or directory, allow to move it accross directories as well.
  33. **/
  34. static function rename( path : String, newpath : String ) : Void;
  35. /**
  36. Returns informations for the given file/directory.
  37. **/
  38. static function stat( path : String ) : FileStat;
  39. /**
  40. Returns the full path for the given path which is relative to the current working directory.
  41. **/
  42. static function fullPath( relpath : String ) : String;
  43. /**
  44. Tells if the given path is a directory. Throw an exception if it does not exists or is not accesible.
  45. **/
  46. static function isDirectory( path : String ) : Bool;
  47. /**
  48. Create the given directory. Not recursive : the parent directory must exists.
  49. **/
  50. static function createDirectory( path : String ) : Void;
  51. /**
  52. Delete a given file.
  53. **/
  54. static function deleteFile( path : String ) : Void;
  55. /**
  56. Delete a given directory.
  57. **/
  58. static function deleteDirectory( path : String ) : Void;
  59. /**
  60. Read all the files/directories stored into the given directory.
  61. **/
  62. static function readDirectory( path : String ) : Array<String>;
  63. }