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


PHP View::touch方法代码示例

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


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

示例1: touch

 /**
  * @param int $mtime
  * @throws \OCP\Files\NotPermittedException
  */
 public function touch($mtime = null)
 {
     if ($this->checkPermissions(\OCP\PERMISSION_UPDATE)) {
         $this->sendHooks(array('preTouch'));
         $this->view->touch($this->path, $mtime);
         $this->sendHooks(array('postTouch'));
     } else {
         throw new NotPermittedException();
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:14,代码来源:node.php

示例2: encryptAll

 /**
  * Encrypt all files in a directory
  * @param string $dirPath the directory whose files will be encrypted
  * @return bool
  * @note Encryption is recursive
  */
 public function encryptAll($dirPath)
 {
     $result = true;
     $found = $this->findEncFiles($dirPath);
     // Disable proxy to prevent file being encrypted twice
     \OC_FileProxy::$enabled = false;
     $versionStatus = \OCP\App::isEnabled('files_versions');
     \OC_App::disable('files_versions');
     $encryptedFiles = array();
     // Encrypt unencrypted files
     foreach ($found['plain'] as $plainFile) {
         //get file info
         $fileInfo = \OC\Files\Filesystem::getFileInfo($plainFile['path']);
         //relative to data/<user>/file
         $relPath = $plainFile['path'];
         //relative to /data
         $rawPath = '/' . $this->userId . '/files/' . $plainFile['path'];
         // keep timestamp
         $timestamp = $fileInfo['mtime'];
         // Open plain file handle for binary reading
         $plainHandle = $this->view->fopen($rawPath, 'rb');
         // Open enc file handle for binary writing, with same filename as original plain file
         $encHandle = fopen('crypt://' . $rawPath . '.part', 'wb');
         if (is_resource($encHandle) && is_resource($plainHandle)) {
             // Move plain file to a temporary location
             $size = stream_copy_to_stream($plainHandle, $encHandle);
             fclose($encHandle);
             fclose($plainHandle);
             $fakeRoot = $this->view->getRoot();
             $this->view->chroot('/' . $this->userId . '/files');
             $this->view->rename($relPath . '.part', $relPath);
             // set timestamp
             $this->view->touch($relPath, $timestamp);
             $encSize = $this->view->filesize($relPath);
             $this->view->chroot($fakeRoot);
             // Add the file to the cache
             \OC\Files\Filesystem::putFileInfo($relPath, array('encrypted' => true, 'size' => $encSize, 'unencrypted_size' => $size, 'etag' => $fileInfo['etag']));
             $encryptedFiles[] = $relPath;
         } else {
             \OCP\Util::writeLog('files_encryption', 'initial encryption: could not encrypt ' . $rawPath, \OCP\Util::FATAL);
             $result = false;
         }
     }
     \OC_FileProxy::$enabled = true;
     if ($versionStatus) {
         \OC_App::enable('files_versions');
     }
     $result = $result && $this->encryptVersions($encryptedFiles);
     return $result;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:56,代码来源:util.php

示例3: touch

 /**
  * @param int $mtime
  * @throws \OCP\Files\NotPermittedException
  */
 public function touch($mtime = null)
 {
     if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) {
         $this->sendHooks(array('preTouch'));
         $this->view->touch($this->path, $mtime);
         $this->sendHooks(array('postTouch'));
         if ($this->fileInfo) {
             if (is_null($mtime)) {
                 $mtime = time();
             }
             $this->fileInfo['mtime'] = $mtime;
         }
     } else {
         throw new NotPermittedException();
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:20,代码来源:node.php

示例4: setUp

 public function setUp()
 {
     $app = new Application();
     $container = $app->getContainer();
     // reset backend
     $um = $container->getServer()->getUserManager();
     $this->userSession = $container->getServer()->getUserSession();
     $um->clearBackends();
     $um->registerBackend(new \OC_User_Database());
     // create test user
     $this->userName = 'test';
     \OC_User::deleteUser($this->userName);
     $um->createUser($this->userName, $this->userName);
     \OC_Util::tearDownFS();
     $this->userSession->setUser(null);
     Filesystem::tearDown();
     \OC_Util::setupFS($this->userName);
     $this->userSession->setUser($um->get($this->userName));
     $view = new \OC\Files\View('/' . $this->userName . '/files');
     // setup files
     $filesToCopy = array('documents' => array('document.pdf', 'document.docx', 'document.odt', 'document.txt'));
     $count = 0;
     foreach ($filesToCopy as $folder => $files) {
         foreach ($files as $file) {
             $imgData = file_get_contents(__DIR__ . '/data/' . $file);
             $view->mkdir($folder);
             $path = $folder . '/' . $file;
             $view->file_put_contents($path, $imgData);
             // set mtime to get fixed sorting with respect to recentFiles
             $count++;
             $view->touch($path, 1000 + $count);
         }
     }
     list($storage, ) = $view->resolvePath('');
     /** @var $storage Storage */
     $this->storage = $storage;
     $this->scanner = $storage->getScanner();
     $this->scanner->scan('');
 }
开发者ID:ntvis,项目名称:search_lucene,代码行数:39,代码来源:testcase.php

示例5: copy_recursive

 /**
  * recursive copy to copy a whole directory
  *
  * @param string $source source path, relative to the users files directory
  * @param string $destination destination path relative to the users root directoy
  * @param \OC\Files\View $view file view for the users root directory
  */
 private static function copy_recursive($source, $destination, $view)
 {
     $size = 0;
     if ($view->is_dir($source)) {
         $view->mkdir($destination);
         $view->touch($destination, $view->filemtime($source));
         foreach ($view->getDirectoryContent($source) as $i) {
             $pathDir = $source . '/' . $i['name'];
             if ($view->is_dir($pathDir)) {
                 $size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view);
             } else {
                 $size += $view->filesize($pathDir);
                 $result = $view->copy($pathDir, $destination . '/' . $i['name']);
                 if (!$result) {
                     throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
                 }
                 $view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir));
             }
         }
     } else {
         $size += $view->filesize($source);
         $result = $view->copy($source, $destination);
         if (!$result) {
             throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
         }
         $view->touch($destination, $view->filemtime($source));
     }
     return $size;
 }
开发者ID:Combustible,项目名称:core,代码行数:36,代码来源:trashbin.php

示例6: touch

 /**
  *  sets the last modification time of the file (mtime) to the value given
  *  in the second parameter or to now if the second param is empty.
  *  Even if the modification time is set to a custom value the access time is set to now.
  */
 public function touch($mtime)
 {
     $this->fileView->touch($this->path, $mtime);
     $this->refreshInfo();
 }
开发者ID:evanjt,项目名称:core,代码行数:10,代码来源:node.php

示例7: 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

示例8: touch

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


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