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


PHP View::unlockFile方法代碼示例

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


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

示例1: testChangeLock

 public function testChangeLock()
 {
     Filesystem::initMountPoints($this->recipientUid);
     $recipientView = new View('/' . $this->recipientUid . '/files');
     $recipientView->lockFile('bar.txt', ILockingProvider::LOCK_SHARED);
     $recipientView->changeLock('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
     $recipientView->unlockFile('bar.txt', ILockingProvider::LOCK_EXCLUSIVE);
     $this->assertTrue(true);
 }
開發者ID:enoch85,項目名稱:owncloud-testserver,代碼行數:9,代碼來源:locking.php

示例2: releaseLock

 /**
  * @param string $path
  * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  * @param \OCP\Lock\ILockingProvider $provider
  */
 public function releaseLock($path, $type, ILockingProvider $provider)
 {
     /** @var \OCP\Files\Storage $targetStorage */
     list($targetStorage, $targetInternalPath) = $this->resolvePath($path);
     $targetStorage->releaseLock($targetInternalPath, $type, $provider);
     // unlock the parent folders of the owner when unlocking the share as recipient
     if ($path === '') {
         $sourcePath = $this->ownerView->getPath($this->share['file_source']);
         $this->ownerView->unlockFile(dirname($sourcePath), ILockingProvider::LOCK_SHARED, true);
     }
 }
開發者ID:GrumpyCrouton,項目名稱:core,代碼行數:16,代碼來源:sharedstorage.php

示例3: isFileLocked

 /**
  * Check if the given path is locked with a given type
  *
  * @param \OC\Files\View $view view
  * @param string $path path to check
  * @param int $type lock type
  * @param bool $onMountPoint true to check the mount point instead of the
  * mounted storage
  *
  * @return boolean true if the file is locked with the
  * given type, false otherwise
  */
 protected function isFileLocked($view, $path, $type, $onMountPoint = false)
 {
     // Note: this seems convoluted but is necessary because
     // the format of the lock key depends on the storage implementation
     // (in our case mostly md5)
     if ($type === \OCP\Lock\ILockingProvider::LOCK_SHARED) {
         // to check if the file has a shared lock, try acquiring an exclusive lock
         $checkType = \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE;
     } else {
         // a shared lock cannot be set if exclusive lock is in place
         $checkType = \OCP\Lock\ILockingProvider::LOCK_SHARED;
     }
     try {
         $view->lockFile($path, $checkType, $onMountPoint);
         // no exception, which means the lock of $type is not set
         // clean up
         $view->unlockFile($path, $checkType, $onMountPoint);
         return false;
     } catch (\OCP\Lock\LockedException $e) {
         // we could not acquire the counter-lock, which means
         // the lock of $type was in place
         return true;
     }
 }
開發者ID:farukuzun,項目名稱:core-1,代碼行數:36,代碼來源:testcase.php

示例4: unlockAllTheFiles

 /**
  * @param string $dir
  * @param $files
  * @param integer $getType
  * @param View $view
  * @param string $filename
  */
 private static function unlockAllTheFiles($dir, $files, $getType, $view, $filename)
 {
     if ($getType === self::FILE) {
         $view->unlockFile($filename, ILockingProvider::LOCK_SHARED);
     }
     if ($getType === self::ZIP_FILES) {
         foreach ($files as $file) {
             $file = $dir . '/' . $file;
             $view->unlockFile($file, ILockingProvider::LOCK_SHARED);
         }
     }
     if ($getType === self::ZIP_DIR) {
         $file = $dir . '/' . $files;
         $view->unlockFile($file, ILockingProvider::LOCK_SHARED);
     }
 }
開發者ID:farukuzun,項目名稱:core-1,代碼行數:23,代碼來源:files.php

示例5: releaseLock

 /**
  * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  */
 public function releaseLock($type)
 {
     $this->fileView->unlockFile($this->path, $type);
 }
開發者ID:evanjt,項目名稱:core,代碼行數:7,代碼來源:node.php

示例6: copyFileContents

 /**
  * Stream copy file contents from $path1 to $path2
  *
  * @param View $view view to use for copying
  * @param string $path1 source file to copy
  * @param string $path2 target file
  *
  * @return bool true for success, false otherwise
  */
 private static function copyFileContents($view, $path1, $path2)
 {
     /** @var \OC\Files\Storage\Storage $storage1 */
     list($storage1, $internalPath1) = $view->resolvePath($path1);
     /** @var \OC\Files\Storage\Storage $storage2 */
     list($storage2, $internalPath2) = $view->resolvePath($path2);
     $view->lockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
     $view->lockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);
     // TODO add a proper way of overwriting a file while maintaining file ids
     if ($storage1->instanceOfStorage('\\OC\\Files\\ObjectStore\\ObjectStoreStorage') || $storage2->instanceOfStorage('\\OC\\Files\\ObjectStore\\ObjectStoreStorage')) {
         $source = $storage1->fopen($internalPath1, 'r');
         $target = $storage2->fopen($internalPath2, 'w');
         list(, $result) = \OC_Helper::streamCopy($source, $target);
         fclose($source);
         fclose($target);
         if ($result !== false) {
             $storage1->unlink($internalPath1);
         }
     } else {
         $result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2);
     }
     $view->unlockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
     $view->unlockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);
     return $result !== false;
 }
開發者ID:gvde,項目名稱:core,代碼行數:34,代碼來源:storage.php

示例7: unlock

 /**
  * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  * @throws \OCP\Lock\LockedException
  */
 public function unlock($type)
 {
     $this->view->unlockFile($this->path, $type);
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:8,代碼來源:Node.php

示例8: copyFileContents

 /**
  * Stream copy file contents from $path1 to $path2
  *
  * @param \OC\Files\View $view view to use for copying
  * @param string $path1 source file to copy
  * @param string $path2 target file
  *
  * @return bool true for success, false otherwise
  */
 private static function copyFileContents($view, $path1, $path2)
 {
     /** @var \OC\Files\Storage\Storage $storage1 */
     list($storage1, $internalPath1) = $view->resolvePath($path1);
     /** @var \OC\Files\Storage\Storage $storage2 */
     list($storage2, $internalPath2) = $view->resolvePath($path2);
     $view->lockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
     $view->lockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);
     $result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2);
     $view->unlockFile($path1, ILockingProvider::LOCK_EXCLUSIVE);
     $view->unlockFile($path2, ILockingProvider::LOCK_EXCLUSIVE);
     return $result !== false;
 }
開發者ID:0x17de,項目名稱:core,代碼行數:22,代碼來源:storage.php


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