Пример #1
0
 /**
  * scan a folder and all it's children
  *
  * @param string $path
  * @param bool $recursive
  * @param int $reuse
  * @param bool $lock set to false to disable getting an additional read lock during scanning
  * @return array an array of the meta data of the scanned file or folder
  */
 public function scan($path, $recursive = self::SCAN_RECURSIVE, $reuse = -1, $lock = true)
 {
     if ($reuse === -1) {
         $reuse = $recursive === self::SCAN_SHALLOW ? self::REUSE_ETAG | self::REUSE_SIZE : self::REUSE_ETAG;
     }
     if ($lock) {
         if ($this->storage->instanceOfStorage('\\OCP\\Files\\Storage\\ILockingStorage')) {
             $this->storage->acquireLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
         }
     }
     $data = $this->scanFile($path, $reuse, -1, null, $lock);
     if ($data and $data['mimetype'] === 'httpd/unix-directory') {
         $size = $this->scanChildren($path, $recursive, $reuse, $data, $lock);
         $data['size'] = $size;
     }
     if ($lock) {
         if ($this->storage->instanceOfStorage('\\OCP\\Files\\Storage\\ILockingStorage')) {
             $this->storage->releaseLock($path, ILockingProvider::LOCK_SHARED, $this->lockingProvider);
         }
     }
     return $data;
 }
Пример #2
0
 /**
  * @param string $path
  * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  * @param \OCP\Lock\ILockingProvider $provider
  */
 public function changeLock($path, $type, ILockingProvider $provider)
 {
     if ($this->storage->instanceOfStorage('\\OCP\\Files\\Storage\\ILockingStorage')) {
         $this->storage->changeLock($path, $type, $provider);
     }
 }
Пример #3
0
 /**
  * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class
  *
  * @param string $class
  * @return bool
  */
 public function instanceOfStorage($class)
 {
     return is_a($this, $class) or $this->storage->instanceOfStorage($class);
 }