FileSystem.hx 3.6 KB

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