FileSystem.hx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * Copyright (C)2005-2017 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 information about the files and directories.
  25. See `sys.io.File` for the complementary file API.
  26. **/
  27. extern class FileSystem {
  28. /**
  29. Tells if the file or directory specified by `path` exists.
  30. If `path` is null, the result is unspecified.
  31. **/
  32. static function exists( path : String ) : Bool;
  33. /**
  34. Renames/moves the file or directory specified by `path` to `newPath`.
  35. If `path` is not a valid file system entry, or if it is not accessible,
  36. or if `newPath` is not accessible, an exception is thrown.
  37. If `path` or `newPath` are null, the result is unspecified.
  38. **/
  39. static function rename( path : String, newPath : String ) : Void;
  40. /**
  41. Returns `FileStat` information on the file or directory specified by
  42. `path`.
  43. If `path` is null, the result is unspecified.
  44. **/
  45. static function stat( path : String ) : FileStat;
  46. /**
  47. Returns the full path of the file or directory specified by `relPath`,
  48. which is relative to the current working directory. Symlinks will be
  49. followed and the path will be normalized.
  50. If `relPath` is null, the result is unspecified.
  51. **/
  52. static function fullPath( relPath : String ) : String;
  53. /**
  54. Returns the full path of the file or directory specified by `relPath`,
  55. which is relative to the current working directory. The path doesn't
  56. have to exist.
  57. If `relPath` is null, the result is unspecified.
  58. **/
  59. //@:require(haxe_ver >= 3.2)
  60. static function absolutePath( relPath : String ) : String;
  61. /**
  62. Tells if the file or directory specified by `path` is a directory.
  63. If `path` is not a valid file system entry or if its destination is not
  64. accessible, an exception is thrown.
  65. If `path` is null, the result is unspecified.
  66. **/
  67. static function isDirectory( path : String ) : Bool;
  68. /**
  69. Creates a directory specified by `path`.
  70. This method is recursive: The parent directories don't have to exist.
  71. If the directory cannot be created, an exception is thrown.
  72. If `path` is null, the result is unspecified.
  73. **/
  74. static function createDirectory( path : String ) : Void;
  75. /**
  76. Deletes the file specified by `path`.
  77. If `path` does not denote a valid file, or if that file cannot be
  78. deleted, an exception is thrown.
  79. If `path` is null, the result is unspecified.
  80. **/
  81. static function deleteFile( path : String ) : Void;
  82. /**
  83. Deletes the directory specified by `path`.
  84. If `path` does not denote a valid directory, or if that directory cannot
  85. be deleted, an exception is thrown.
  86. If `path` is null, the result is unspecified.
  87. **/
  88. static function deleteDirectory( path : String ) : Void;
  89. /**
  90. Returns the names of all files and directories in the directory specified
  91. by `path`.
  92. If `path` does not denote a valid directory, an exception is thrown.
  93. If `path` is null, the result is unspecified.
  94. **/
  95. static function readDirectory( path : String ) : Array<String>;
  96. }