Touchable.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * Hoa
  4. *
  5. *
  6. * @license
  7. *
  8. * New BSD License
  9. *
  10. * Copyright © 2007-2017, Hoa community. All rights reserved.
  11. *
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions are met:
  14. * * Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * * Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. * * Neither the name of the Hoa nor the names of its contributors may be
  20. * used to endorse or promote products derived from this software without
  21. * specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. namespace Hoa\Stream\IStream;
  36. /**
  37. * Interface \Hoa\Stream\IStream\Touchable.
  38. *
  39. * Interface for touchable input/output.
  40. *
  41. * @copyright Copyright © 2007-2017 Hoa community
  42. * @license New BSD License
  43. */
  44. interface Touchable extends Stream
  45. {
  46. /**
  47. * Overwrite file if already exists.
  48. *
  49. * @const bool
  50. */
  51. const OVERWRITE = true;
  52. /**
  53. * Do not overwrite file if already exists.
  54. *
  55. * @const bool
  56. */
  57. const DO_NOT_OVERWRITE = false;
  58. /**
  59. * Make directory if does not exist.
  60. *
  61. * @const bool
  62. */
  63. const MAKE_DIRECTORY = true;
  64. /**
  65. * Do not make directory if does not exist.
  66. *
  67. * @const bool
  68. */
  69. const DO_NOT_MAKE_DIRECTORY = false;
  70. /**
  71. * Set access and modification time of file.
  72. *
  73. * @param int $time Time. If equals to -1, time() should be used.
  74. * @param int $atime Access time. If equals to -1, $time should be
  75. * used.
  76. * @return bool
  77. */
  78. public function touch($time = -1, $atime = -1);
  79. /**
  80. * Copy file.
  81. * Return the destination file path if succeed, false otherwise.
  82. *
  83. * @param string $to Destination path.
  84. * @param bool $force Force to copy if the file $to already exists.
  85. * Use the self::*OVERWRITE constants.
  86. * @return bool
  87. */
  88. public function copy($to, $force = self::DO_NOT_OVERWRITE);
  89. /**
  90. * Move a file.
  91. *
  92. * @param string $name New name.
  93. * @param bool $force Force to move if the file $name already
  94. * exists.
  95. * Use the self::*OVERWRITE constants.
  96. * @param bool $mkdir Force to make directory if does not exist.
  97. * Use the self::*DIRECTORY constants.
  98. * @return bool
  99. */
  100. public function move(
  101. $name,
  102. $force = self::DO_NOT_OVERWRITE,
  103. $mkdir = self::DO_NOT_MAKE_DIRECTORY
  104. );
  105. /**
  106. * Delete a file.
  107. *
  108. * @return bool
  109. */
  110. public function delete();
  111. /**
  112. * Change file group.
  113. *
  114. * @param mixed $group Group name or number.
  115. * @return bool
  116. */
  117. public function changeGroup($group);
  118. /**
  119. * Change file mode.
  120. *
  121. * @param int $mode Mode (in octal!).
  122. * @return bool
  123. */
  124. public function changeMode($mode);
  125. /**
  126. * Change file owner.
  127. *
  128. * @param mixed $user User.
  129. * @return bool
  130. */
  131. public function changeOwner($user);
  132. /**
  133. * Change the current umask.
  134. *
  135. * @param int $umask Umask (in octal!). If null, given the current
  136. * umask value.
  137. * @return int
  138. */
  139. public static function umask($umask = null);
  140. }