当前位置: 首页>>代码示例>>PHP>>正文


PHP View::copy方法代码示例

本文整理汇总了PHP中OC\Files\View::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP View::copy方法的具体用法?PHP View::copy怎么用?PHP View::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC\Files\View的用法示例。


在下文中一共展示了View::copy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: copy

 /**
  * Copies a file or directory.
  *
  * This method must work recursively and delete the destination
  * if it exists
  *
  * @param string $source
  * @param string $destination
  * @throws \Sabre\DAV\Exception\ServiceUnavailable
  * @return void
  */
 public function copy($source, $destination)
 {
     if (!$this->fileView) {
         throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
     }
     // this will trigger existence check
     $this->getNodeForPath($source);
     list($destinationDir, $destinationName) = \Sabre\HTTP\URLUtil::splitPath($destination);
     try {
         $this->fileView->verifyPath($destinationDir, $destinationName);
     } catch (\OCP\Files\InvalidPathException $ex) {
         throw new InvalidPath($ex->getMessage());
     }
     try {
         $this->fileView->copy($source, $destination);
     } catch (StorageNotAvailableException $e) {
         throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
     } catch (ForbiddenException $ex) {
         throw new Forbidden($ex->getMessage(), $ex->getRetry());
     } catch (LockedException $e) {
         throw new FileLocked($e->getMessage(), $e->getCode(), $e);
     }
     list($destinationDir, ) = \Sabre\HTTP\URLUtil::splitPath($destination);
     $this->markDirty($destinationDir);
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:36,代码来源:objecttree.php

示例2: copy

 /**
  * Copies a file or directory.
  *
  * This method must work recursively and delete the destination
  * if it exists
  *
  * @param string $source
  * @param string $destination
  * @throws \Sabre\DAV\Exception\ServiceUnavailable
  * @return void
  */
 public function copy($source, $destination)
 {
     if (!$this->fileView) {
         throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
     }
     try {
         if ($this->fileView->is_file($source)) {
             $this->fileView->copy($source, $destination);
         } else {
             $this->fileView->mkdir($destination);
             $dh = $this->fileView->opendir($source);
             if (is_resource($dh)) {
                 while (($subNode = readdir($dh)) !== false) {
                     if ($subNode == '.' || $subNode == '..') {
                         continue;
                     }
                     $this->copy($source . '/' . $subNode, $destination . '/' . $subNode);
                 }
             }
         }
     } catch (\OCP\Files\StorageNotAvailableException $e) {
         throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
     }
     list($destinationDir, ) = \Sabre\DAV\URLUtil::splitPath($destination);
     $this->markDirty($destinationDir);
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:37,代码来源:objecttree.php

示例3: backupUserKeys

 /**
  * create backup of user specific keys
  *
  * @param string $user
  * @return bool
  */
 private function backupUserKeys($user)
 {
     $encryptionDir = $user . '/files_encryption';
     if ($this->view->is_dir($encryptionDir)) {
         $backupDir = $user . '/encryption_migration_backup_' . date("Y-m-d_H-i-s");
         $this->view->mkdir($backupDir);
         $this->view->copy($encryptionDir, $backupDir);
         return true;
     }
     return false;
 }
开发者ID:brunomilet,项目名称:owncloud-core,代码行数:17,代码来源:migration.php

示例4: copyKeys

 /**
  * copy keys if a file was renamed
  *
  * @param string $source
  * @param string $target
  * @return boolean
  */
 public function copyKeys($source, $target)
 {
     $sourcePath = $this->getPathToKeys($source);
     $targetPath = $this->getPathToKeys($target);
     if ($this->view->file_exists($sourcePath)) {
         $this->keySetPreparation(dirname($targetPath));
         $this->view->copy($sourcePath, $targetPath);
         return true;
     }
     return false;
 }
开发者ID:samj1912,项目名称:repo,代码行数:18,代码来源:storage.php

示例5: backupAllKeys

 /**
  * create a backup of all keys from the user
  *
  * @param string $purpose define the purpose of the backup, will be part of the backup folder name
  * @param boolean $timestamp (optional) should a timestamp be added, default true
  * @param boolean $includeUserKeys (optional) include users private-/public-key, default true
  */
 public function backupAllKeys($purpose, $timestamp = true, $includeUserKeys = true)
 {
     $this->userId;
     $backupDir = $this->encryptionDir . '/backup.' . $purpose;
     $backupDir .= $timestamp ? '.' . date("Y-m-d_H-i-s") . '/' : '/';
     $this->view->mkdir($backupDir);
     $this->view->copy($this->keysPath, $backupDir . 'keys/');
     if ($includeUserKeys) {
         $this->view->copy($this->privateKeyPath, $backupDir . $this->userId . '.privateKey');
         $this->view->copy($this->publicKeyPath, $backupDir . $this->userId . '.publicKey');
     }
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:19,代码来源:util.php

示例6: encryptFile

 /**
  * encrypt file
  *
  * @param string $path
  * @return bool
  */
 protected function encryptFile($path)
 {
     $source = $path;
     $target = $path . '.encrypted.' . time();
     try {
         $this->rootView->copy($source, $target);
         $this->rootView->rename($target, $source);
     } catch (DecryptionFailedException $e) {
         if ($this->rootView->file_exists($target)) {
             $this->rootView->unlink($target);
         }
         return false;
     }
     return true;
 }
开发者ID:ErikPel,项目名称:core,代码行数:21,代码来源:encryptall.php

示例7: copy

 /**
  * Copies a file or directory.
  *
  * This method must work recursively and delete the destination
  * if it exists
  *
  * @param string $source
  * @param string $destination
  * @throws \Sabre\DAV\Exception\ServiceUnavailable
  * @return void
  */
 public function copy($source, $destination)
 {
     if (!$this->fileView) {
         throw new \Sabre\DAV\Exception\ServiceUnavailable('filesystem not setup');
     }
     // this will trigger existence check
     $this->getNodeForPath($source);
     try {
         $this->fileView->copy($source, $destination);
     } catch (\OCP\Files\StorageNotAvailableException $e) {
         throw new \Sabre\DAV\Exception\ServiceUnavailable($e->getMessage());
     }
     list($destinationDir, ) = \Sabre\HTTP\URLUtil::splitPath($destination);
     $this->markDirty($destinationDir);
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:26,代码来源:objecttree.php

示例8: copyKeys

 /**
  * copy keys if a file was renamed
  *
  * @param string $source
  * @param string $target
  * @param string $owner
  * @param bool $systemWide
  */
 public function copyKeys($source, $target)
 {
     list($owner, $source) = $this->util->getUidAndFilename($source);
     list(, $target) = $this->util->getUidAndFilename($target);
     $systemWide = $this->util->isSystemWideMountPoint($target);
     if ($systemWide) {
         $sourcePath = $this->keys_base_dir . $source . '/';
         $targetPath = $this->keys_base_dir . $target . '/';
     } else {
         $sourcePath = '/' . $owner . $this->keys_base_dir . $source . '/';
         $targetPath = '/' . $owner . $this->keys_base_dir . $target . '/';
     }
     if ($this->view->file_exists($sourcePath)) {
         $this->keySetPreparation(dirname($targetPath));
         $this->view->copy($sourcePath, $targetPath);
     }
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:25,代码来源:storage.php

示例9: renameShareKeys

 private function renameShareKeys($user, $filePath, $filename, $target, $trash)
 {
     $oldShareKeyPath = $this->getOldShareKeyPath($user, $filePath, $trash);
     $dh = $this->view->opendir($oldShareKeyPath);
     if (is_resource($dh)) {
         while (($file = readdir($dh)) !== false) {
             if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
                 if ($this->view->is_dir($oldShareKeyPath . '/' . $file)) {
                     continue;
                 } else {
                     if (substr($file, 0, strlen($filename) + 1) === $filename . '.') {
                         $uid = $this->getUidFromShareKey($file, $filename, $trash);
                         $this->view->copy($oldShareKeyPath . '/' . $file, $target . '/' . $uid . '.shareKey');
                     }
                 }
             }
         }
         closedir($dh);
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:20,代码来源:migration.php

示例10: rollback

 /**
  * Rollback to an old version of a file.
  *
  * @param string $file file name
  * @param int $revision revision timestamp
  */
 public static function rollback($file, $revision)
 {
     if (\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED) == 'true') {
         // add expected leading slash
         $file = '/' . ltrim($file, '/');
         list($uid, $filename) = self::getUidAndFilename($file);
         $users_view = new View('/' . $uid);
         $files_view = new View('/' . User::getUser() . '/files');
         $versionCreated = false;
         //first create a new version
         $version = 'files_versions' . $filename . '.v' . $users_view->filemtime('files' . $filename);
         if (!$users_view->file_exists($version)) {
             $users_view->copy('files' . $filename, 'files_versions' . $filename . '.v' . $users_view->filemtime('files' . $filename));
             $versionCreated = true;
         }
         $fileToRestore = 'files_versions' . $filename . '.v' . $revision;
         // Restore encrypted version of the old file for the newly restored file
         // This has to happen manually here since the file is manually copied below
         $oldVersion = $users_view->getFileInfo($fileToRestore)->getEncryptedVersion();
         $newFileInfo = $files_view->getFileInfo($filename);
         $cache = $newFileInfo->getStorage()->getCache();
         $cache->update($newFileInfo->getId(), ['encrypted' => $oldVersion, 'encryptedVersion' => $oldVersion]);
         // rollback
         if (self::copyFileContents($users_view, $fileToRestore, 'files' . $filename)) {
             $files_view->touch($file, $revision);
             Storage::scheduleExpire($uid, $file);
             \OC_Hook::emit('\\OCP\\Versions', 'rollback', array('path' => $filename, 'revision' => $revision));
             return true;
         } else {
             if ($versionCreated) {
                 self::deleteVersion($users_view, $version);
             }
         }
     }
     return false;
 }
开发者ID:gvde,项目名称:core,代码行数:42,代码来源:storage.php

示例11: copy

 public static function copy($path1, $path2)
 {
     return self::$defaultInstance->copy($path1, $path2);
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:4,代码来源:Filesystem.php


注:本文中的OC\Files\View::copy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。