IShare.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2014 Robin Appelman <robin@icewind.nl>
  4. * SPDX-License-Identifier: MIT
  5. */
  6. namespace Icewind\SMB;
  7. use Icewind\SMB\Exception\AlreadyExistsException;
  8. use Icewind\SMB\Exception\InvalidRequestException;
  9. use Icewind\SMB\Exception\InvalidTypeException;
  10. use Icewind\SMB\Exception\NotFoundException;
  11. interface IShare {
  12. /**
  13. * Get the name of the share
  14. *
  15. * @return string
  16. */
  17. public function getName(): string;
  18. /**
  19. * Download a remote file
  20. *
  21. * @param string $source remote file
  22. * @param string $target local file
  23. * @return bool
  24. *
  25. * @throws NotFoundException
  26. * @throws InvalidTypeException
  27. */
  28. public function get(string $source, string $target): bool;
  29. /**
  30. * Upload a local file
  31. *
  32. * @param string $source local file
  33. * @param string $target remote file
  34. * @return bool
  35. *
  36. * @throws NotFoundException
  37. * @throws InvalidTypeException
  38. */
  39. public function put(string $source, string $target): bool;
  40. /**
  41. * Open a readable stream to a remote file
  42. *
  43. * @param string $source
  44. * @return resource a read only stream with the contents of the remote file
  45. *
  46. * @throws NotFoundException
  47. * @throws InvalidTypeException
  48. */
  49. public function read(string $source);
  50. /**
  51. * Open a writable stream to a remote file
  52. * Note: This method will truncate the file to 0bytes
  53. *
  54. * @param string $target
  55. * @return resource a write only stream to upload a remote file
  56. *
  57. * @throws NotFoundException
  58. * @throws InvalidTypeException
  59. */
  60. public function write(string $target);
  61. /**
  62. * Open a writable stream to a remote file and set the cursor to the end of the file
  63. *
  64. * @param string $target
  65. * @return resource a write only stream to upload a remote file
  66. *
  67. * @throws NotFoundException
  68. * @throws InvalidTypeException
  69. * @throws InvalidRequestException
  70. */
  71. public function append(string $target);
  72. /**
  73. * Rename a remote file
  74. *
  75. * @param string $from
  76. * @param string $to
  77. * @return bool
  78. *
  79. * @throws NotFoundException
  80. * @throws AlreadyExistsException
  81. */
  82. public function rename(string $from, string $to): bool;
  83. /**
  84. * Delete a file on the share
  85. *
  86. * @param string $path
  87. * @return bool
  88. *
  89. * @throws NotFoundException
  90. * @throws InvalidTypeException
  91. */
  92. public function del(string $path): bool;
  93. /**
  94. * List the content of a remote folder
  95. *
  96. * @param string $path
  97. * @return IFileInfo[]
  98. *
  99. * @throws NotFoundException
  100. * @throws InvalidTypeException
  101. */
  102. public function dir(string $path): array;
  103. /**
  104. * @param string $path
  105. * @return IFileInfo
  106. *
  107. * @throws NotFoundException
  108. */
  109. public function stat(string $path): IFileInfo;
  110. /**
  111. * Create a folder on the share
  112. *
  113. * @param string $path
  114. * @return bool
  115. *
  116. * @throws NotFoundException
  117. * @throws AlreadyExistsException
  118. */
  119. public function mkdir(string $path): bool;
  120. /**
  121. * Remove a folder on the share
  122. *
  123. * @param string $path
  124. * @return bool
  125. *
  126. * @throws NotFoundException
  127. * @throws InvalidTypeException
  128. */
  129. public function rmdir(string $path): bool;
  130. /**
  131. * @param string $path
  132. * @param int $mode a combination of FileInfo::MODE_READONLY, FileInfo::MODE_ARCHIVE, FileInfo::MODE_SYSTEM and FileInfo::MODE_HIDDEN, FileInfo::NORMAL
  133. * @return mixed
  134. */
  135. public function setMode(string $path, int $mode);
  136. /**
  137. * @param string $path
  138. * @return INotifyHandler
  139. */
  140. public function notify(string $path);
  141. /**
  142. * Get the IServer instance for this share
  143. *
  144. * @return IServer
  145. */
  146. public function getServer(): IServer;
  147. }