當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Filesystem::resolvePath方法代碼示例

本文整理匯總了PHP中OC\Files\Filesystem::resolvePath方法的典型用法代碼示例。如果您正苦於以下問題:PHP Filesystem::resolvePath方法的具體用法?PHP Filesystem::resolvePath怎麽用?PHP Filesystem::resolvePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OC\Files\Filesystem的用法示例。


在下文中一共展示了Filesystem::resolvePath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getNodeForPath

 /**
  * Returns the INode object for the requested path
  *
  * @param string $path
  * @throws \Sabre_DAV_Exception_NotFound
  * @return \Sabre_DAV_INode
  */
 public function getNodeForPath($path)
 {
     $path = trim($path, '/');
     if (isset($this->cache[$path])) {
         return $this->cache[$path];
     }
     // Is it the root node?
     if (!strlen($path)) {
         return $this->rootNode;
     }
     if (pathinfo($path, PATHINFO_EXTENSION) === 'part') {
         // read from storage
         $absPath = $this->getFileView()->getAbsolutePath($path);
         list($storage, $internalPath) = Filesystem::resolvePath('/' . $absPath);
         if ($storage) {
             $scanner = $storage->getScanner($internalPath);
             // get data directly
             $info = $scanner->getData($internalPath);
         }
     } else {
         // read from cache
         $info = $this->getFileView()->getFileInfo($path);
     }
     if (!$info) {
         throw new \Sabre_DAV_Exception_NotFound('File with name ' . $path . ' could not be located');
     }
     if ($info['mimetype'] === 'httpd/unix-directory') {
         $node = new \OC_Connector_Sabre_Directory($path);
     } else {
         $node = new \OC_Connector_Sabre_File($path);
     }
     $node->setFileinfoCache($info);
     $this->cache[$path] = $node;
     return $node;
 }
開發者ID:hjimmy,項目名稱:owncloud,代碼行數:42,代碼來源:objecttree.php

示例2: isExcludedPath

 /**
  * check if path is excluded from encryption
  *
  * @param string $path relative to data/
  * @return boolean
  */
 protected function isExcludedPath($path)
 {
     $view = new \OC\Files\View();
     $normalizedPath = \OC\Files\Filesystem::normalizePath($path);
     $parts = explode('/', $normalizedPath);
     // we only encrypt/decrypt files in the files and files_versions folder
     if (sizeof($parts) < 3) {
         /**
          * Less then 3 parts means, we can't match:
          * - /{$uid}/files/* nor
          * - /{$uid}/files_versions/*
          * So this is not a path we are looking for.
          */
         return true;
     }
     if (!($parts[2] === 'files' && \OCP\User::userExists($parts[1])) && !($parts[2] === 'files_versions' && \OCP\User::userExists($parts[1]))) {
         return true;
     }
     if (!$view->file_exists($normalizedPath)) {
         $normalizedPath = dirname($normalizedPath);
     }
     // we don't encrypt server-to-server shares
     list($storage, ) = \OC\Files\Filesystem::resolvePath($normalizedPath);
     /**
      * @var \OCP\Files\Storage $storage
      */
     if ($storage->instanceOfStorage('OCA\\Files_Sharing\\External\\Storage')) {
         return true;
     }
     return false;
 }
開發者ID:samj1912,項目名稱:repo,代碼行數:37,代碼來源:proxy.php

示例3: propagateChange

 /**
  * @param string $internalPath
  * @param int $time
  * @return array[] all propagated entries
  */
 public function propagateChange($internalPath, $time)
 {
     $source = $this->storage->getSourcePath($internalPath);
     /** @var \OC\Files\Storage\Storage $storage */
     list($storage, $sourceInternalPath) = \OC\Files\Filesystem::resolvePath($source);
     return $storage->getPropagator()->propagateChange($sourceInternalPath, $time);
 }
開發者ID:kenwi,項目名稱:core,代碼行數:12,代碼來源:sharedpropagator.php

示例4: testParentOfMountPointIsGone

 /**
  * if the parent of the mount point is gone then the mount point should move up
  *
  * @medium
  */
 function testParentOfMountPointIsGone()
 {
     // share to user
     $fileinfo = $this->view->getFileInfo($this->folder);
     $result = \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $user2View = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     $this->assertTrue($user2View->file_exists($this->folder));
     // create a local folder
     $result = $user2View->mkdir('localfolder');
     $this->assertTrue($result);
     // move mount point to local folder
     $result = $user2View->rename($this->folder, '/localfolder/' . $this->folder);
     $this->assertTrue($result);
     // mount point in the root folder should no longer exist
     $this->assertFalse($user2View->is_dir($this->folder));
     // delete the local folder
     /** @var \OC\Files\Storage\Storage $storage */
     list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/localfolder');
     $storage->rmdir($internalPath);
     //enforce reload of the mount points
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     //mount point should be back at the root
     $this->assertTrue($user2View->is_dir($this->folder));
     //cleanup
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->view->unlink($this->folder);
 }
開發者ID:evanjt,項目名稱:core,代碼行數:34,代碼來源:sharedstorage.php

示例5: getSourceCache

 /**
  * Get the source cache of a shared file or folder
  *
  * @param string $target Shared target file path
  * @return \OC\Files\Cache\Cache
  */
 private function getSourceCache($target)
 {
     if ($target === false || $target === $this->storage->getMountPoint()) {
         $target = '';
     }
     $source = \OC_Share_Backend_File::getSource($target, $this->storage->getMountPoint(), $this->storage->getItemType());
     if (isset($source['path']) && isset($source['fileOwner'])) {
         try {
             \OC\Files\Filesystem::initMountPoints($source['fileOwner']);
         } catch (NoUserException $e) {
             \OC::$server->getLogger()->warning('The user \'' . $source['uid_owner'] . '\' of a share can\'t be retrieved.', array('app' => 'files_sharing'));
             return false;
         }
         $mounts = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
         if (is_array($mounts) and !empty($mounts)) {
             $fullPath = $mounts[0]->getMountPoint() . $source['path'];
             list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($fullPath);
             if ($storage) {
                 $this->files[$target] = $internalPath;
                 $cache = $storage->getCache();
                 $this->storageId = $storage->getId();
                 $this->numericId = $cache->getNumericStorageId();
                 return $cache;
             }
         }
     }
     return false;
 }
開發者ID:droiter,項目名稱:openwrt-on-android,代碼行數:34,代碼來源:cache.php

示例6: getData

 /**
  * Returns metadata from the shared storage, but
  * with permissions from the source storage.
  *
  * @param string $path path of the file for which to retrieve metadata
  *
  * @return array an array of metadata of the file
  */
 protected function getData($path)
 {
     $data = parent::getData($path);
     $sourcePath = $this->storage->getSourcePath($path);
     list($sourceStorage, $internalPath) = \OC\Files\Filesystem::resolvePath($sourcePath);
     $data['permissions'] = $sourceStorage->getPermissions($internalPath);
     return $data;
 }
開發者ID:kenwi,項目名稱:core,代碼行數:16,代碼來源:scanner.php

示例7: __construct

 public function __construct($user = null)
 {
     if (is_null($user)) {
         $user = \OCP\User::getUser();
     }
     $root = $user . '/files/';
     list($storage, $internalPath) = Filesystem::resolvePath($root);
     $this->fileview = new View($root);
     $this->cache = new Cache($storage);
 }
開發者ID:amin-hedayati,項目名稱:videos,代碼行數:10,代碼來源:videos.php

示例8: setKey

 /**
  * write key to disk
  *
  *
  * @param string $path path to key directory
  * @param string $name key name
  * @param string $key key
  * @param \OC\Files\View $view
  * @return bool
  */
 private static function setKey($path, $name, $key, $view)
 {
     self::keySetPreparation($view, $path);
     /** @var \OCP\Files\Storage $storage */
     $pathToKey = \OC\Files\Filesystem::normalizePath($path . '/' . $name);
     list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($pathToKey);
     $result = $storage->file_put_contents($internalPath, $key);
     if (is_int($result) && $result > 0) {
         self::$key_cache[$pathToKey] = $key;
         return true;
     }
     return false;
 }
開發者ID:samj1912,項目名稱:repo,代碼行數:23,代碼來源:keymanager.php

示例9: getNodeForPath

 /**
  * Returns the INode object for the requested path
  *
  * @param string $path
  * @throws \Sabre\DAV\Exception\ServiceUnavailable
  * @throws \Sabre\DAV\Exception\NotFound
  * @return \Sabre\DAV\INode
  */
 public function getNodeForPath($path)
 {
     if (!$this->fileView) {
         throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
     }
     $path = trim($path, '/');
     if (isset($this->cache[$path])) {
         return $this->cache[$path];
     }
     // Is it the root node?
     if (!strlen($path)) {
         return $this->rootNode;
     }
     if (pathinfo($path, PATHINFO_EXTENSION) === 'part') {
         // read from storage
         $absPath = $this->fileView->getAbsolutePath($path);
         list($storage, $internalPath) = Filesystem::resolvePath('/' . $absPath);
         if ($storage) {
             /**
              * @var \OC\Files\Storage\Storage $storage
              */
             $scanner = $storage->getScanner($internalPath);
             // get data directly
             $data = $scanner->getData($internalPath);
             $info = new FileInfo($absPath, $storage, $internalPath, $data);
         } else {
             $info = null;
         }
     } else {
         // read from cache
         try {
             $info = $this->fileView->getFileInfo($path);
         } catch (StorageNotAvailableException $e) {
             throw new \Sabre\DAV\Exception\ServiceUnavailable('Storage not available');
         } catch (StorageInvalidException $e) {
             throw new \Sabre\DAV\Exception\NotFound('Storage ' . $path . ' is invalid');
         }
     }
     if (!$info) {
         throw new \Sabre\DAV\Exception\NotFound('File with name ' . $path . ' could not be located');
     }
     if ($info->getType() === 'dir') {
         $node = new \OC_Connector_Sabre_Directory($this->fileView, $info);
     } else {
         $node = new \OC_Connector_Sabre_File($this->fileView, $info);
     }
     $this->cache[$path] = $node;
     return $node;
 }
開發者ID:WYSAC,項目名稱:oregon-owncloud,代碼行數:57,代碼來源:objecttree.php

示例10: getFreeSpace

 /**
  * get the free space in the path's owner home folder
  * @param path
  * @return int
  */
 private function getFreeSpace($path)
 {
     /**
      * @var \OC\Files\Storage\Storage $storage
      * @var string $internalPath
      */
     list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($path);
     $owner = $storage->getOwner($internalPath);
     if (!$owner) {
         return -1;
     }
     $totalSpace = $this->getQuota($owner);
     if ($totalSpace == -1) {
         return -1;
     }
     $view = new \OC\Files\View("/" . $owner . "/files");
     $rootInfo = $view->getFileInfo('/');
     $usedSpace = isset($rootInfo['size']) ? $rootInfo['size'] : 0;
     return $totalSpace - $usedSpace;
 }
開發者ID:CDN-Sparks,項目名稱:owncloud,代碼行數:25,代碼來源:quota.php

示例11: getSourceCache

 /**
  * @brief Get the source cache of a shared file or folder
  * @param string $target Shared target file path
  * @return \OC\Files\Cache\Cache
  */
 private function getSourceCache($target)
 {
     $source = \OC_Share_Backend_File::getSource($target);
     if (isset($source['path']) && isset($source['fileOwner'])) {
         \OC\Files\Filesystem::initMountPoints($source['fileOwner']);
         $mount = \OC\Files\Mount::findByNumericId($source['storage']);
         if ($mount) {
             $fullPath = $mount->getMountPoint() . $source['path'];
             list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($fullPath);
             if ($storage) {
                 $this->files[$target] = $internalPath;
                 $cache = $storage->getCache();
                 $this->storageId = $storage->getId();
                 $this->numericId = $cache->getNumericStorageId();
                 return $cache;
             }
         }
     }
     return false;
 }
開發者ID:CDN-Sparks,項目名稱:owncloud,代碼行數:25,代碼來源:cache.php

示例12: isExcludedPath

 /**
  * check if path is excluded from encryption
  *
  * @param string $path relative to data/
  * @param string $uid user
  * @return boolean
  */
 private function isExcludedPath($path, $uid)
 {
     $view = new \OC\Files\View();
     // files outside of the files-folder are excluded
     if (strpos($path, '/' . $uid . '/files') !== 0) {
         return true;
     }
     if (!$view->file_exists($path)) {
         $path = dirname($path);
     }
     // we don't encrypt server-to-server shares
     list($storage, ) = \OC\Files\Filesystem::resolvePath($path);
     /**
      * @var \OCP\Files\Storage $storage
      */
     if ($storage->instanceOfStorage('OCA\\Files_Sharing\\External\\Storage')) {
         return true;
     }
     return false;
 }
開發者ID:olucao,項目名稱:owncloud-core,代碼行數:27,代碼來源:proxy.php

示例13: isExcludedPath

 /**
  * check if path is excluded from encryption
  *
  * @param string $path relative to data/
  * @param string $uid user
  * @return boolean
  */
 protected function isExcludedPath($path, $uid)
 {
     $view = new \OC\Files\View();
     $path = \OC\Files\Filesystem::normalizePath($path);
     // we only encrypt/decrypt files in the files and files_versions folder
     if (strpos($path, '/' . $uid . '/files/') !== 0 && strpos($path, '/' . $uid . '/files_versions/') !== 0) {
         return true;
     }
     if (!$view->file_exists($path)) {
         $path = dirname($path);
     }
     // we don't encrypt server-to-server shares
     list($storage, ) = \OC\Files\Filesystem::resolvePath($path);
     /**
      * @var \OCP\Files\Storage $storage
      */
     if ($storage->instanceOfStorage('OCA\\Files_Sharing\\External\\Storage')) {
         return true;
     }
     return false;
 }
開發者ID:WYSAC,項目名稱:oregon-owncloud,代碼行數:28,代碼來源:proxy.php

示例14: getSourceCache

	/**
	 * Get the source cache of a shared file or folder
	 *
	 * @param string $target Shared target file path
	 * @return \OC\Files\Cache\Cache
	 */
	private function getSourceCache($target) {
		if ($target === false || $target === $this->storage->getMountPoint()) {
			$target = '';
		}
		$source = \OC_Share_Backend_File::getSource($target, $this->storage->getMountPoint(), $this->storage->getItemType());
		if (isset($source['path']) && isset($source['fileOwner'])) {
			\OC\Files\Filesystem::initMountPoints($source['fileOwner']);
			$mounts = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
			if (is_array($mounts) and !empty($mounts)) {
				$fullPath = $mounts[0]->getMountPoint() . $source['path'];
				list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($fullPath);
				if ($storage) {
					$this->files[$target] = $internalPath;
					$cache = $storage->getCache();
					$this->storageId = $storage->getId();
					$this->numericId = $cache->getNumericStorageId();
					return $cache;
				}
			}
		}
		return false;
	}
開發者ID:BacLuc,項目名稱:newGryfiPage,代碼行數:28,代碼來源:cache.php

示例15: isTargetAllowed

 /**
  * check if it is allowed to move a mount point to a given target.
  * It is not allowed to move a mount point into a different mount point
  *
  * @param string $target path
  * @return boolean
  */
 private function isTargetAllowed($target)
 {
     $result = false;
     list($targetStorage, ) = \OC\Files\Filesystem::resolvePath($target);
     if ($targetStorage->instanceOfStorage('\\OCP\\Files\\IHomeStorage')) {
         $result = true;
     } else {
         \OCP\Util::writeLog('files', 'It is not allowed to move one mount point into another one', \OCP\Util::DEBUG);
     }
     return $result;
 }
開發者ID:adolfo2103,項目名稱:hcloudfilem,代碼行數:18,代碼來源:view.php


注:本文中的OC\Files\Filesystem::resolvePath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。