1
0

Storage.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\Files\Storage;
  8. use OCP\Lock\ILockingProvider;
  9. /**
  10. * Provide a common interface to all different storage options
  11. *
  12. * All paths passed to the storage are relative to the storage and should NOT have a leading slash.
  13. */
  14. interface Storage extends \OCP\Files\Storage {
  15. /**
  16. * get a cache instance for the storage
  17. *
  18. * @param string $path
  19. * @param \OC\Files\Storage\Storage|null (optional) the storage to pass to the cache
  20. * @return \OC\Files\Cache\Cache
  21. */
  22. public function getCache($path = '', $storage = null);
  23. /**
  24. * get a scanner instance for the storage
  25. *
  26. * @param string $path
  27. * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner
  28. * @return \OC\Files\Cache\Scanner
  29. */
  30. public function getScanner($path = '', $storage = null);
  31. /**
  32. * get the user id of the owner of a file or folder
  33. *
  34. * @param string $path
  35. * @return string
  36. */
  37. public function getOwner($path);
  38. /**
  39. * get a watcher instance for the cache
  40. *
  41. * @param string $path
  42. * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
  43. * @return \OC\Files\Cache\Watcher
  44. */
  45. public function getWatcher($path = '', $storage = null);
  46. /**
  47. * get a propagator instance for the cache
  48. *
  49. * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
  50. * @return \OC\Files\Cache\Propagator
  51. */
  52. public function getPropagator($storage = null);
  53. /**
  54. * get a updater instance for the cache
  55. *
  56. * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher
  57. * @return \OC\Files\Cache\Updater
  58. */
  59. public function getUpdater($storage = null);
  60. /**
  61. * @return \OC\Files\Cache\Storage
  62. */
  63. public function getStorageCache();
  64. /**
  65. * @param string $path
  66. * @return array|null
  67. */
  68. public function getMetaData($path);
  69. /**
  70. * @param string $path The path of the file to acquire the lock for
  71. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  72. * @param \OCP\Lock\ILockingProvider $provider
  73. * @throws \OCP\Lock\LockedException
  74. */
  75. public function acquireLock($path, $type, ILockingProvider $provider);
  76. /**
  77. * @param string $path The path of the file to release the lock for
  78. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  79. * @param \OCP\Lock\ILockingProvider $provider
  80. * @throws \OCP\Lock\LockedException
  81. */
  82. public function releaseLock($path, $type, ILockingProvider $provider);
  83. /**
  84. * @param string $path The path of the file to change the lock for
  85. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  86. * @param \OCP\Lock\ILockingProvider $provider
  87. * @throws \OCP\Lock\LockedException
  88. */
  89. public function changeLock($path, $type, ILockingProvider $provider);
  90. /**
  91. * Get the contents of a directory with metadata
  92. *
  93. * @param string $directory
  94. * @return \Traversable an iterator, containing file metadata
  95. *
  96. * The metadata array will contain the following fields
  97. *
  98. * - name
  99. * - mimetype
  100. * - mtime
  101. * - size
  102. * - etag
  103. * - storage_mtime
  104. * - permissions
  105. */
  106. public function getDirectoryContent($directory): \Traversable;
  107. }