PhpStreamWrapperInterface.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. namespace Drupal\Core\StreamWrapper;
  3. /**
  4. * Defines a generic PHP stream wrapper interface.
  5. *
  6. * @see http://php.net/manual/class.streamwrapper.php
  7. */
  8. interface PhpStreamWrapperInterface {
  9. /**
  10. * @return bool
  11. */
  12. public function dir_closedir();
  13. /**
  14. * @return bool
  15. */
  16. public function dir_opendir($path, $options);
  17. /**
  18. * @return string
  19. */
  20. public function dir_readdir();
  21. /**
  22. * @return bool
  23. */
  24. public function dir_rewinddir();
  25. /**
  26. * @return bool
  27. */
  28. public function mkdir($path, $mode, $options);
  29. /**
  30. * @return bool
  31. */
  32. public function rename($path_from, $path_to);
  33. /**
  34. * @return bool
  35. */
  36. public function rmdir($path, $options);
  37. /**
  38. * Retrieve the underlying stream resource.
  39. *
  40. * This method is called in response to stream_select().
  41. *
  42. * @param int $cast_as
  43. * Can be STREAM_CAST_FOR_SELECT when stream_select() is calling
  44. * stream_cast() or STREAM_CAST_AS_STREAM when stream_cast() is called for
  45. * other uses.
  46. *
  47. * @return resource|false
  48. * The underlying stream resource or FALSE if stream_select() is not
  49. * supported.
  50. *
  51. * @see stream_select()
  52. * @see http://php.net/manual/streamwrapper.stream-cast.php
  53. */
  54. public function stream_cast($cast_as);
  55. /**
  56. * Closes stream.
  57. */
  58. public function stream_close();
  59. /**
  60. * @return bool
  61. */
  62. public function stream_eof();
  63. /**
  64. * @return bool
  65. */
  66. public function stream_flush();
  67. /**
  68. * @return bool
  69. */
  70. public function stream_lock($operation);
  71. /**
  72. * Sets metadata on the stream.
  73. *
  74. * @param string $path
  75. * A string containing the URI to the file to set metadata on.
  76. * @param int $option
  77. * One of:
  78. * - STREAM_META_TOUCH: The method was called in response to touch().
  79. * - STREAM_META_OWNER_NAME: The method was called in response to chown()
  80. * with string parameter.
  81. * - STREAM_META_OWNER: The method was called in response to chown().
  82. * - STREAM_META_GROUP_NAME: The method was called in response to chgrp().
  83. * - STREAM_META_GROUP: The method was called in response to chgrp().
  84. * - STREAM_META_ACCESS: The method was called in response to chmod().
  85. * @param mixed $value
  86. * If option is:
  87. * - STREAM_META_TOUCH: Array consisting of two arguments of the touch()
  88. * function.
  89. * - STREAM_META_OWNER_NAME or STREAM_META_GROUP_NAME: The name of the owner
  90. * user/group as string.
  91. * - STREAM_META_OWNER or STREAM_META_GROUP: The value of the owner
  92. * user/group as integer.
  93. * - STREAM_META_ACCESS: The argument of the chmod() as integer.
  94. *
  95. * @return bool
  96. * Returns TRUE on success or FALSE on failure. If $option is not
  97. * implemented, FALSE should be returned.
  98. *
  99. * @see http://php.net/manual/streamwrapper.stream-metadata.php
  100. */
  101. public function stream_metadata($path, $option, $value);
  102. /**
  103. * @return bool
  104. */
  105. public function stream_open($path, $mode, $options, &$opened_path);
  106. /**
  107. * @return string
  108. */
  109. public function stream_read($count);
  110. /**
  111. * Seeks to specific location in a stream.
  112. *
  113. * This method is called in response to fseek().
  114. *
  115. * The read/write position of the stream should be updated according to the
  116. * offset and whence.
  117. *
  118. * @param int $offset
  119. * The byte offset to seek to.
  120. * @param int $whence
  121. * Possible values:
  122. * - SEEK_SET: Set position equal to offset bytes.
  123. * - SEEK_CUR: Set position to current location plus offset.
  124. * - SEEK_END: Set position to end-of-file plus offset.
  125. * Defaults to SEEK_SET.
  126. *
  127. * @return bool
  128. * TRUE if the position was updated, FALSE otherwise.
  129. *
  130. * @see http://php.net/manual/streamwrapper.stream-seek.php
  131. */
  132. public function stream_seek($offset, $whence = SEEK_SET);
  133. /**
  134. * Change stream options.
  135. *
  136. * This method is called to set options on the stream.
  137. *
  138. * @param int $option
  139. * One of:
  140. * - STREAM_OPTION_BLOCKING: The method was called in response to
  141. * stream_set_blocking().
  142. * - STREAM_OPTION_READ_TIMEOUT: The method was called in response to
  143. * stream_set_timeout().
  144. * - STREAM_OPTION_WRITE_BUFFER: The method was called in response to
  145. * stream_set_write_buffer().
  146. * @param int $arg1
  147. * If option is:
  148. * - STREAM_OPTION_BLOCKING: The requested blocking mode:
  149. * - 1 means blocking.
  150. * - 0 means not blocking.
  151. * - STREAM_OPTION_READ_TIMEOUT: The timeout in seconds.
  152. * - STREAM_OPTION_WRITE_BUFFER: The buffer mode, STREAM_BUFFER_NONE or
  153. * STREAM_BUFFER_FULL.
  154. * @param int $arg2
  155. * If option is:
  156. * - STREAM_OPTION_BLOCKING: This option is not set.
  157. * - STREAM_OPTION_READ_TIMEOUT: The timeout in microseconds.
  158. * - STREAM_OPTION_WRITE_BUFFER: The requested buffer size.
  159. *
  160. * @return bool
  161. * TRUE on success, FALSE otherwise. If $option is not implemented, FALSE
  162. * should be returned.
  163. */
  164. public function stream_set_option($option, $arg1, $arg2);
  165. /**
  166. * @return array
  167. */
  168. public function stream_stat();
  169. /**
  170. * @return int
  171. */
  172. public function stream_tell();
  173. /**
  174. * Truncate stream.
  175. *
  176. * Will respond to truncation; e.g., through ftruncate().
  177. *
  178. * @param int $new_size
  179. * The new size.
  180. *
  181. * @return bool
  182. * TRUE on success, FALSE otherwise.
  183. */
  184. public function stream_truncate($new_size);
  185. /**
  186. * @return int
  187. */
  188. public function stream_write($data);
  189. /**
  190. * @return bool
  191. */
  192. public function unlink($path);
  193. /**
  194. * @return array
  195. */
  196. public function url_stat($path, $flags);
  197. }