本文整理汇总了PHP中OC\Files\Mount\Manager::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Manager::find方法的具体用法?PHP Manager::find怎么用?PHP Manager::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC\Files\Mount\Manager
的用法示例。
在下文中一共展示了Manager::find方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeShare
public function removeShare($mountPoint)
{
$mountPointObj = $this->mountManager->find($mountPoint);
$id = $mountPointObj->getStorage()->getCache()->getId('');
$mountPoint = $this->stripPath($mountPoint);
$hash = md5($mountPoint);
$getShare = $this->connection->prepare('
SELECT `remote`, `share_token`, `remote_id`
FROM `*PREFIX*share_external`
WHERE `mountpoint_hash` = ? AND `user` = ?');
$result = $getShare->execute(array($hash, $this->uid));
if ($result) {
$share = $getShare->fetch();
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'decline');
}
$getShare->closeCursor();
$query = $this->connection->prepare('
DELETE FROM `*PREFIX*share_external`
WHERE `mountpoint_hash` = ?
AND `user` = ?
');
$result = (bool) $query->execute(array($hash, $this->uid));
if ($result) {
$this->removeReShares($id);
}
return $result;
}
示例2: move
/**
* Moves a file from one location to another
*
* @param string $sourcePath The path to the file which should be moved
* @param string $destinationPath The full destination path, so not just the destination parent node
* @throws \Sabre\DAV\Exception\BadRequest
* @throws \Sabre\DAV\Exception\ServiceUnavailable
* @throws \Sabre\DAV\Exception\Forbidden
* @return int
*/
public function move($sourcePath, $destinationPath)
{
if (!$this->fileView) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
}
$targetNodeExists = $this->nodeExists($destinationPath);
$sourceNode = $this->getNodeForPath($sourcePath);
if ($sourceNode instanceof \Sabre\DAV\ICollection && $targetNodeExists) {
throw new \Sabre\DAV\Exception\Forbidden('Could not copy directory ' . $sourceNode . ', target exists');
}
list($sourceDir, ) = \Sabre\HTTP\URLUtil::splitPath($sourcePath);
list($destinationDir, ) = \Sabre\HTTP\URLUtil::splitPath($destinationPath);
$isMovableMount = false;
$sourceMount = $this->mountManager->find($this->fileView->getAbsolutePath($sourcePath));
$internalPath = $sourceMount->getInternalPath($this->fileView->getAbsolutePath($sourcePath));
if ($sourceMount instanceof MoveableMount && $internalPath === '') {
$isMovableMount = true;
}
try {
$sameFolder = $sourceDir === $destinationDir;
// if we're overwriting or same folder
if ($targetNodeExists || $sameFolder) {
// note that renaming a share mount point is always allowed
if (!$this->fileView->isUpdatable($destinationDir) && !$isMovableMount) {
throw new \Sabre\DAV\Exception\Forbidden();
}
} else {
if (!$this->fileView->isCreatable($destinationDir)) {
throw new \Sabre\DAV\Exception\Forbidden();
}
}
if (!$sameFolder) {
// moving to a different folder, source will be gone, like a deletion
// note that moving a share mount point is always allowed
if (!$this->fileView->isDeletable($sourcePath) && !$isMovableMount) {
throw new \Sabre\DAV\Exception\Forbidden();
}
}
$fileName = basename($destinationPath);
try {
$this->fileView->verifyPath($destinationDir, $fileName);
} catch (\OCP\Files\InvalidPathException $ex) {
throw new InvalidPath($ex->getMessage());
}
$renameOkay = $this->fileView->rename($sourcePath, $destinationPath);
if (!$renameOkay) {
throw new \Sabre\DAV\Exception\Forbidden('');
}
} catch (StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
} catch (LockedException $e) {
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
$this->markDirty($sourceDir);
$this->markDirty($destinationDir);
}
示例3: move
/**
* Moves a file from one location to another
*
* @param string $sourcePath The path to the file which should be moved
* @param string $destinationPath The full destination path, so not just the destination parent node
* @throws \Sabre\DAV\Exception\BadRequest
* @throws \Sabre\DAV\Exception\ServiceUnavailable
* @throws \Sabre\DAV\Exception\Forbidden
* @return int
*/
public function move($sourcePath, $destinationPath)
{
if (!$this->fileView) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
}
$targetNodeExists = $this->nodeExists($destinationPath);
$sourceNode = $this->getNodeForPath($sourcePath);
if ($sourceNode instanceof \Sabre\DAV\ICollection && $targetNodeExists) {
throw new \Sabre\DAV\Exception\Forbidden('Could not copy directory ' . $sourceNode . ', target exists');
}
list($sourceDir, ) = \Sabre\DAV\URLUtil::splitPath($sourcePath);
list($destinationDir, ) = \Sabre\DAV\URLUtil::splitPath($destinationPath);
$isMovableMount = false;
$sourceMount = $this->mountManager->find($this->fileView->getAbsolutePath($sourcePath));
$internalPath = $sourceMount->getInternalPath($this->fileView->getAbsolutePath($sourcePath));
if ($sourceMount instanceof MoveableMount && $internalPath === '') {
$isMovableMount = true;
}
try {
$sameFolder = $sourceDir === $destinationDir;
// if we're overwriting or same folder
if ($targetNodeExists || $sameFolder) {
// note that renaming a share mount point is always allowed
if (!$this->fileView->isUpdatable($destinationDir) && !$isMovableMount) {
throw new \Sabre\DAV\Exception\Forbidden();
}
} else {
if (!$this->fileView->isCreatable($destinationDir)) {
throw new \Sabre\DAV\Exception\Forbidden();
}
}
if (!$sameFolder) {
// moving to a different folder, source will be gone, like a deletion
// note that moving a share mount point is always allowed
if (!$this->fileView->isDeletable($sourcePath) && !$isMovableMount) {
throw new \Sabre\DAV\Exception\Forbidden();
}
}
$fileName = basename($destinationPath);
if (!\OCP\Util::isValidFileName($fileName)) {
throw new \Sabre\DAV\Exception\BadRequest();
}
$renameOkay = $this->fileView->rename($sourcePath, $destinationPath);
if (!$renameOkay) {
throw new \Sabre\DAV\Exception\Forbidden('');
}
} catch (\OCP\Files\StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
}
// update properties
$query = \OC_DB::prepare('UPDATE `*PREFIX*properties` SET `propertypath` = ?' . ' WHERE `userid` = ? AND `propertypath` = ?');
$query->execute(array(\OC\Files\Filesystem::normalizePath($destinationPath), \OC_User::getUser(), \OC\Files\Filesystem::normalizePath($sourcePath)));
$this->markDirty($sourceDir);
$this->markDirty($destinationDir);
}
示例4: assertNotMount
private function assertNotMount($mountPoint)
{
$mountPoint = rtrim($mountPoint, '/');
$mount = $this->mountManager->find($this->getFullPath($mountPoint));
if ($mount) {
$this->assertInstanceOf('\\OCP\\Files\\Mount\\IMountPoint', $mount);
$this->assertNotEquals($this->getFullPath($mountPoint), rtrim($mount->getMountPoint(), '/'));
} else {
$this->assertNull($mount);
}
}
示例5: resolvePath
/**
* resolve a path to a storage and internal path
*
* @param string $path
* @return array an array consisting of the storage and the internal path
*/
static public function resolvePath($path) {
if (!self::$mounts) {
\OC_Util::setupFS();
}
$mount = self::$mounts->find($path);
if ($mount) {
return array($mount->getStorage(), $mount->getInternalPath($path));
} else {
return array(null, null);
}
}
示例6: move
/**
* Moves a file from one location to another
*
* @param string $sourcePath The path to the file which should be moved
* @param string $destinationPath The full destination path, so not just the destination parent node
* @throws \Sabre\DAV\Exception\BadRequest
* @throws \Sabre\DAV\Exception\ServiceUnavailable
* @throws \Sabre\DAV\Exception\Forbidden
* @return int
*/
public function move($sourcePath, $destinationPath)
{
if (!$this->fileView) {
throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
}
$sourceNode = $this->getNodeForPath($sourcePath);
if ($sourceNode instanceof \Sabre\DAV\ICollection and $this->nodeExists($destinationPath)) {
throw new \Sabre\DAV\Exception\Forbidden('Could not copy directory ' . $sourceNode . ', target exists');
}
list($sourceDir, ) = \Sabre\DAV\URLUtil::splitPath($sourcePath);
list($destinationDir, ) = \Sabre\DAV\URLUtil::splitPath($destinationPath);
$isMovableMount = false;
$sourceMount = $this->mountManager->find($this->fileView->getAbsolutePath($sourcePath));
$internalPath = $sourceMount->getInternalPath($this->fileView->getAbsolutePath($sourcePath));
if ($sourceMount instanceof MoveableMount && $internalPath === '') {
$isMovableMount = true;
}
try {
// check update privileges
if (!$this->fileView->isUpdatable($sourcePath) && !$isMovableMount) {
throw new \Sabre\DAV\Exception\Forbidden();
}
if ($sourceDir !== $destinationDir) {
if (!$this->fileView->isCreatable($destinationDir)) {
throw new \Sabre\DAV\Exception\Forbidden();
}
if (!$this->fileView->isDeletable($sourcePath) && !$isMovableMount) {
throw new \Sabre\DAV\Exception\Forbidden();
}
}
$fileName = basename($destinationPath);
if (!\OCP\Util::isValidFileName($fileName)) {
throw new \Sabre\DAV\Exception\BadRequest();
}
$renameOkay = $this->fileView->rename($sourcePath, $destinationPath);
if (!$renameOkay) {
throw new \Sabre\DAV\Exception\Forbidden('');
}
} catch (\OCP\Files\StorageNotAvailableException $e) {
throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
}
// update properties
$query = \OC_DB::prepare('UPDATE `*PREFIX*properties` SET `propertypath` = ?' . ' WHERE `userid` = ? AND `propertypath` = ?');
$query->execute(array(\OC\Files\Filesystem::normalizePath($destinationPath), \OC_User::getUser(), \OC\Files\Filesystem::normalizePath($sourcePath)));
$this->markDirty($sourceDir);
$this->markDirty($destinationDir);
}
示例7: update
/**
* update keyfiles and share keys recursively
*
* @param int $fileSource file source id
*/
private function update($fileSource)
{
$path = \OC\Files\Filesystem::getPath($fileSource);
$info = \OC\Files\Filesystem::getFileInfo($path);
$owner = \OC\Files\Filesystem::getOwner($path);
$view = new \OC\Files\View('/' . $owner . '/files');
$ownerPath = $view->getPath($info->getId());
$absPath = '/' . $owner . '/files' . $ownerPath;
$mount = $this->mountManager->find($path);
$mountPoint = $mount->getMountPoint();
// if a folder was shared, get a list of all (sub-)folders
if ($this->view->is_dir($absPath)) {
$allFiles = $this->util->getAllFiles($absPath, $mountPoint);
} else {
$allFiles = array($absPath);
}
$encryptionModule = $this->encryptionManager->getDefaultEncryptionModule();
foreach ($allFiles as $path) {
$usersSharing = $this->file->getAccessList($path);
$encryptionModule->update($path, $this->uid, $usersSharing);
}
}
示例8: testFind
public function testFind()
{
$this->assertNull($this->manager->find('/'));
$rootMount = new \OC\Files\Mount\MountPoint(new Temporary(array()), '/');
$this->manager->addMount($rootMount);
$this->assertEquals($rootMount, $this->manager->find('/'));
$this->assertEquals($rootMount, $this->manager->find('/foo/bar'));
$storage = new Temporary(array());
$mount1 = new \OC\Files\Mount\MountPoint($storage, '/foo');
$this->manager->addMount($mount1);
$this->assertEquals($rootMount, $this->manager->find('/'));
$this->assertEquals($mount1, $this->manager->find('/foo/bar'));
$this->assertEquals(1, count($this->manager->findIn('/')));
$mount2 = new \OC\Files\Mount\MountPoint(new Temporary(array()), '/bar');
$this->manager->addMount($mount2);
$this->assertEquals(2, count($this->manager->findIn('/')));
$id = $mount1->getStorageId();
$this->assertEquals(array($mount1), $this->manager->findByStorageId($id));
$mount3 = new \OC\Files\Mount\MountPoint($storage, '/foo/bar');
$this->manager->addMount($mount3);
$this->assertEquals(array($mount1, $mount3), $this->manager->findByStorageId($id));
}
示例9: getMount
/**
* @param string $mountPoint
* @return \OC\Files\Mount\MountPoint
*/
public function getMount($mountPoint)
{
return $this->mountManager->find($mountPoint);
}