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


PHP View::opendir方法代码示例

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


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

示例1: listCertificates

 /**
  * Returns all certificates trusted by the user
  *
  * @return \OCP\ICertificate[]
  */
 public function listCertificates()
 {
     if (!$this->config->getSystemValue('installed', false)) {
         return array();
     }
     $path = $this->getPathToCertificates() . 'uploads/';
     if (!$this->view->is_dir($path)) {
         return array();
     }
     $result = array();
     $handle = $this->view->opendir($path);
     if (!is_resource($handle)) {
         return array();
     }
     while (false !== ($file = readdir($handle))) {
         if ($file != '.' && $file != '..') {
             try {
                 $result[] = new Certificate($this->view->file_get_contents($path . $file), $file);
             } catch (\Exception $e) {
             }
         }
     }
     closedir($handle);
     return $result;
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:30,代码来源:CertificateManager.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: renameFileKeys

 /**
  * rename file keys
  *
  * @param string $user
  * @param string $path
  * @param bool $trash
  */
 private function renameFileKeys($user, $path, $trash = false)
 {
     if ($this->view->is_dir($user . '/' . $path) === false) {
         $this->logger->info('Skip dir /' . $user . '/' . $path . ': does not exist');
         return;
     }
     $dh = $this->view->opendir($user . '/' . $path);
     if (is_resource($dh)) {
         while (($file = readdir($dh)) !== false) {
             if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
                 if ($this->view->is_dir($user . '/' . $path . '/' . $file)) {
                     $this->renameFileKeys($user, $path . '/' . $file, $trash);
                 } else {
                     $target = $this->getTargetDir($user, $path, $file, $trash);
                     if ($target) {
                         $this->createPathForKeys(dirname($target));
                         $this->view->rename($user . '/' . $path . '/' . $file, $target);
                     } else {
                         $this->logger->warning('did not move key "' . $file . '" could not find the corresponding file in /data/' . $user . '/files.' . 'Most likely the key was already moved in a previous migration run and is already on the right place.');
                     }
                 }
             }
         }
         closedir($dh);
     }
 }
开发者ID:jzee,项目名称:core,代码行数:33,代码来源:migration.php

示例4: findEncFiles

 /**
  * Find all files and their encryption status within a directory
  * @param string $directory The path of the parent directory to search
  * @param bool $found the founded files if called again
  * @return array keys: plain, encrypted, broken
  * @note $directory needs to be a path relative to OC data dir. e.g.
  *       /admin/files NOT /backup OR /home/www/oc/data/admin/files
  */
 public function findEncFiles($directory, &$found = false)
 {
     // Disable proxy - we don't want files to be decrypted before
     // we handle them
     \OC_FileProxy::$enabled = false;
     if ($found === false) {
         $found = array('plain' => array(), 'encrypted' => array(), 'broken' => array());
     }
     if ($this->view->is_dir($directory) && ($handle = $this->view->opendir($directory))) {
         if (is_resource($handle)) {
             while (false !== ($file = readdir($handle))) {
                 if ($file !== "." && $file !== "..") {
                     // skip stray part files
                     if (Helper::isPartialFilePath($file)) {
                         continue;
                     }
                     $filePath = $directory . '/' . $this->view->getRelativePath('/' . $file);
                     $relPath = Helper::stripUserFilesPath($filePath);
                     // If the path is a directory, search
                     // its contents
                     if ($this->view->is_dir($filePath)) {
                         $this->findEncFiles($filePath, $found);
                         // If the path is a file, determine
                         // its encryption status
                     } elseif ($this->view->is_file($filePath)) {
                         // Disable proxies again, some-
                         // where they got re-enabled :/
                         \OC_FileProxy::$enabled = false;
                         $isEncryptedPath = $this->isEncryptedPath($filePath);
                         // If the file is encrypted
                         // NOTE: If the userId is
                         // empty or not set, file will
                         // detected as plain
                         // NOTE: This is inefficient;
                         // scanning every file like this
                         // will eat server resources :(
                         if ($isEncryptedPath) {
                             $fileKey = Keymanager::getFileKey($this->view, $this, $relPath);
                             $shareKey = Keymanager::getShareKey($this->view, $this->userId, $this, $relPath);
                             // if file is encrypted but now file key is available, throw exception
                             if ($fileKey === false || $shareKey === false) {
                                 \OCP\Util::writeLog('encryption library', 'No keys available to decrypt the file: ' . $filePath, \OCP\Util::ERROR);
                                 $found['broken'][] = array('name' => $file, 'path' => $filePath);
                             } else {
                                 $found['encrypted'][] = array('name' => $file, 'path' => $filePath);
                             }
                             // If the file is not encrypted
                         } else {
                             $found['plain'][] = array('name' => $file, 'path' => $relPath);
                         }
                     }
                 }
             }
         }
     }
     \OC_FileProxy::$enabled = true;
     return $found;
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:66,代码来源:util.php

示例5: dir_opendir

 public function dir_opendir($path, $options)
 {
     $this->setup();
     $path = substr($path, strlen('oc://'));
     $this->path = $path;
     $this->dirSource = self::$rootView->opendir($path);
     if (is_resource($this->dirSource)) {
         $this->meta = stream_get_meta_data($this->dirSource);
     }
     return is_resource($this->dirSource);
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:11,代码来源:oc.php

示例6: renameFileKeys

 /**
  * rename file keys
  *
  * @param string $user
  * @param string $path
  * @param bool $trash
  */
 private function renameFileKeys($user, $path, $trash = false)
 {
     $dh = $this->view->opendir($user . '/' . $path);
     if (is_resource($dh)) {
         while (($file = readdir($dh)) !== false) {
             if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
                 if ($this->view->is_dir($user . '/' . $path . '/' . $file)) {
                     $this->renameFileKeys($user, $path . '/' . $file, $trash);
                 } else {
                     $target = $this->getTargetDir($user, $path, $file, $trash);
                     $this->createPathForKeys(dirname($target));
                     $this->view->rename($user . '/' . $path . '/' . $file, $target);
                 }
             }
         }
         closedir($dh);
     }
 }
开发者ID:brunomilet,项目名称:owncloud-core,代码行数:25,代码来源:migration.php

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

示例8: recursiveDelShareKeys

 /**
  * recursively delete share keys from given users
  *
  * @param string $dir directory
  * @param array $userIds user ids for which the share keys should be deleted
  * @param string $owner owner of the file
  * @param \OC\Files\View $view view relative to data/
  */
 private static function recursiveDelShareKeys($dir, $userIds, $owner, $view)
 {
     $dirContent = $view->opendir($dir);
     $dirSlices = explode('/', ltrim($dir, '/'));
     $realFileDir = '/' . $owner . '/files/' . implode('/', array_slice($dirSlices, 3)) . '/';
     if (is_resource($dirContent)) {
         while (($file = readdir($dirContent)) !== false) {
             if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
                 if ($view->is_dir($dir . '/' . $file)) {
                     self::recursiveDelShareKeys($dir . '/' . $file, $userIds, $owner, $view);
                 } else {
                     $realFile = $realFileDir . self::getFilenameFromShareKey($file);
                     foreach ($userIds as $userId) {
                         if (preg_match("/(.*)." . $userId . ".shareKey/", $file)) {
                             if ($userId === $owner && $view->file_exists($realFile)) {
                                 \OCP\Util::writeLog('files_encryption', 'original file still exists, keep owners share key!', \OCP\Util::ERROR);
                                 continue;
                             }
                             \OCP\Util::writeLog('files_encryption', 'recursiveDelShareKey: delete share key: ' . $file, \OCP\Util::DEBUG);
                             $view->unlink($dir . '/' . $file);
                         }
                     }
                 }
             }
         }
         closedir($dirContent);
     }
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:36,代码来源:keymanager.php

示例9: isEmpty

 /**
  * check if trash bin is empty for a given user
  *
  * @param string $user
  * @return bool
  */
 public static function isEmpty($user)
 {
     $view = new \OC\Files\View('/' . $user . '/files_trashbin');
     if ($view->is_dir('/files') && ($dh = $view->opendir('/files'))) {
         while ($file = readdir($dh)) {
             if ($file !== '.' and $file !== '..') {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:julakali,项目名称:core,代码行数:18,代码来源:trashbin.php

示例10: getVersions

 /**
  * get a list of all available versions of a file in descending chronological order
  * @param string $uid user id from the owner of the file
  * @param string $filename file to find versions of, relative to the user files dir
  * @param string $userFullPath
  * @return array versions newest version first
  */
 public static function getVersions($uid, $filename, $userFullPath = '')
 {
     $versions = array();
     if (empty($filename)) {
         return $versions;
     }
     // fetch for old versions
     $view = new View('/' . $uid . '/');
     $pathinfo = pathinfo($filename);
     $versionedFile = $pathinfo['basename'];
     $dir = Filesystem::normalizePath(self::VERSIONS_ROOT . '/' . $pathinfo['dirname']);
     $dirContent = false;
     if ($view->is_dir($dir)) {
         $dirContent = $view->opendir($dir);
     }
     if ($dirContent === false) {
         return $versions;
     }
     if (is_resource($dirContent)) {
         while (($entryName = readdir($dirContent)) !== false) {
             if (!Filesystem::isIgnoredDir($entryName)) {
                 $pathparts = pathinfo($entryName);
                 $filename = $pathparts['filename'];
                 if ($filename === $versionedFile) {
                     $pathparts = pathinfo($entryName);
                     $timestamp = substr($pathparts['extension'], 1);
                     $filename = $pathparts['filename'];
                     $key = $timestamp . '#' . $filename;
                     $versions[$key]['version'] = $timestamp;
                     $versions[$key]['humanReadableTimestamp'] = self::getHumanReadableTimestamp($timestamp);
                     if (empty($userFullPath)) {
                         $versions[$key]['preview'] = '';
                     } else {
                         $versions[$key]['preview'] = \OCP\Util::linkToRoute('core_ajax_versions_preview', array('file' => $userFullPath, 'version' => $timestamp));
                     }
                     $versions[$key]['path'] = Filesystem::normalizePath($pathinfo['dirname'] . '/' . $filename);
                     $versions[$key]['name'] = $versionedFile;
                     $versions[$key]['size'] = $view->filesize($dir . '/' . $entryName);
                 }
             }
         }
         closedir($dirContent);
     }
     // sort with newest version first
     krsort($versions);
     return $versions;
 }
开发者ID:gvde,项目名称:core,代码行数:54,代码来源:storage.php

示例11: opendir

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

示例12: isEmpty

 /**
  * check if trash bin is empty for a given user
  *
  * @param string $user
  * @return bool
  */
 public static function isEmpty($user)
 {
     $view = new View('/' . $user . '/files_trashbin');
     if ($view->is_dir('/files') && ($dh = $view->opendir('/files'))) {
         while ($file = readdir($dh)) {
             if (!Filesystem::isIgnoredDir($file)) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:18,代码来源:Trashbin.php

示例13: recursiveDelShareKeys

 /**
  * recursively delete share keys from given users
  *
  * @param string $dir directory
  * @param array $userIds user ids for which the share keys should be deleted
  * @param \OC\Files\View $view view relative to data/
  */
 private static function recursiveDelShareKeys($dir, $userIds, $view)
 {
     $dirContent = $view->opendir($dir);
     if (is_resource($dirContent)) {
         while (($file = readdir($dirContent)) !== false) {
             if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
                 if ($view->is_dir($dir . '/' . $file)) {
                     self::recursiveDelShareKeys($dir . '/' . $file, $userIds, $view);
                 } else {
                     foreach ($userIds as $userId) {
                         if ($userId . '.shareKey' === $file) {
                             \OCP\Util::writeLog('files_encryption', 'recursiveDelShareKey: delete share key: ' . $file, \OCP\Util::DEBUG);
                             self::deleteKey($view, $dir . '/' . $file);
                         }
                     }
                 }
             }
         }
         closedir($dirContent);
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:28,代码来源:keymanager.php

示例14: findShareKeys

 /**
  * find all share keys for a given file
  * @param string $path to the file
  * @param \OC\Files\View $view view, relative to data/
  * @return array list of files, path relative to data/
  */
 public static function findShareKeys($path, $view)
 {
     $result = array();
     $pathinfo = pathinfo($path);
     $dirContent = $view->opendir($pathinfo['dirname']);
     if (is_resource($dirContent)) {
         while (($file = readdir($dirContent)) !== false) {
             if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
                 if (preg_match("/" . $pathinfo['filename'] . ".(.*).shareKey/", $file)) {
                     $result[] = $pathinfo['dirname'] . '/' . $file;
                 }
             }
         }
         closedir($dirContent);
     }
     return $result;
 }
开发者ID:Combustible,项目名称:core,代码行数:23,代码来源:helper.php


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