2
0

FileSystem.hx 3.6 KB

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