FileSystem.hx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 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. static function absPath( relPath : String ) : String;
  60. /**
  61. Tells if the file or directory specified by `path` is a directory.
  62. If `path` is not a valid file system entry or if its destination is no
  63. accessible, an exception is thrown.
  64. If `path` is null, the result is unspecified.
  65. **/
  66. static function isDirectory( path : String ) : Bool;
  67. /**
  68. Creates a directory specified by `path`.
  69. This method is recursive: The parent directories don't have to exist.
  70. If the directory cannot be created, an exception is thrown.
  71. If `path` is null, the result is unspecified.
  72. **/
  73. static function createDirectory( path : String ) : Void;
  74. /**
  75. Deletes the file specified by `path`.
  76. If `path` does not denote a valid file, or if that file cannot be
  77. deleted, an exception is thrown.
  78. If `path` is null, the result is unspecified.
  79. **/
  80. static function deleteFile( path : String ) : Void;
  81. /**
  82. Deletes the directory specified by `path`.
  83. If `path` does not denote a valid directory, or if that directory cannot
  84. be deleted, an exception is thrown.
  85. If `path` is null, the result is unspecified.
  86. **/
  87. static function deleteDirectory( path : String ) : Void;
  88. /**
  89. Returns the names of all files and directories in the directory specified
  90. by `path`.
  91. If `path` does not denote a valid directory, an exception is thrown.
  92. If `path` is null, the result is unspecified.
  93. **/
  94. static function readDirectory( path : String ) : Array<String>;
  95. }