Storage.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OC\Files\Storage;
  26. use OCP\Lock\ILockingProvider;
  27. /**
  28. * Provide a common interface to all different storage options
  29. *
  30. * All paths passed to the storage are relative to the storage and should NOT have a leading slash.
  31. */
  32. interface Storage extends \OCP\Files\Storage {
  33. /**
  34. * get a cache instance for the storage
  35. *
  36. * @param string $path
  37. * @param \OC\Files\Storage\Storage|null (optional) the storage to pass to the cache
  38. * @return \OC\Files\Cache\Cache
  39. */
  40. public function getCache($path = '', $storage = null);
  41. /**
  42. * get a scanner instance for the storage
  43. *
  44. * @param string $path
  45. * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
  46. * @return \OC\Files\Cache\Scanner
  47. */
  48. public function getScanner($path = '', $storage = null);
  49. /**
  50. * get the user id of the owner of a file or folder
  51. *
  52. * @param string $path
  53. * @return string
  54. */
  55. public function getOwner($path);
  56. /**
  57. * get a watcher instance for the cache
  58. *
  59. * @param string $path
  60. * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
  61. * @return \OC\Files\Cache\Watcher
  62. */
  63. public function getWatcher($path = '', $storage = null);
  64. /**
  65. * get a propagator instance for the cache
  66. *
  67. * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
  68. * @return \OC\Files\Cache\Propagator
  69. */
  70. public function getPropagator($storage = null);
  71. /**
  72. * get a updater instance for the cache
  73. *
  74. * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
  75. * @return \OC\Files\Cache\Updater
  76. */
  77. public function getUpdater($storage = null);
  78. /**
  79. * @return \OC\Files\Cache\Storage
  80. */
  81. public function getStorageCache();
  82. /**
  83. * @param string $path
  84. * @return array|null
  85. */
  86. public function getMetaData($path);
  87. /**
  88. * @param string $path The path of the file to acquire the lock for
  89. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  90. * @param \OCP\Lock\ILockingProvider $provider
  91. * @throws \OCP\Lock\LockedException
  92. */
  93. public function acquireLock($path, $type, ILockingProvider $provider);
  94. /**
  95. * @param string $path The path of the file to release the lock for
  96. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  97. * @param \OCP\Lock\ILockingProvider $provider
  98. * @throws \OCP\Lock\LockedException
  99. */
  100. public function releaseLock($path, $type, ILockingProvider $provider);
  101. /**
  102. * @param string $path The path of the file to change the lock for
  103. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  104. * @param \OCP\Lock\ILockingProvider $provider
  105. * @throws \OCP\Lock\LockedException
  106. */
  107. public function changeLock($path, $type, ILockingProvider $provider);
  108. /**
  109. * Get the contents of a directory with metadata
  110. *
  111. * @param string $directory
  112. * @return \Traversable an iterator, containing file metadata
  113. *
  114. * The metadata array will contain the following fields
  115. *
  116. * - name
  117. * - mimetype
  118. * - mtime
  119. * - size
  120. * - etag
  121. * - storage_mtime
  122. * - permissions
  123. */
  124. public function getDirectoryContent($directory): \Traversable;
  125. }