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


PHP Filesystem::getMountPoints方法代码示例

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


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

示例1: getFileInfo

 /**
  * get the filesystem info
  *
  * @param string $path
  * @param boolean|string $includeMountPoints true to add mountpoint sizes,
  * 'ext' to add only ext storage mount point sizes. Defaults to true.
  * defaults to true
  * @return \OC\Files\FileInfo|false
  */
 public function getFileInfo($path, $includeMountPoints = true)
 {
     $this->assertPathLength($path);
     $data = array();
     if (!Filesystem::isValidPath($path)) {
         return $data;
     }
     if (Cache\Scanner::isPartialFile($path)) {
         return $this->getPartFileInfo($path);
     }
     $path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
     $mount = Filesystem::getMountManager()->find($path);
     $storage = $mount->getStorage();
     $internalPath = $mount->getInternalPath($path);
     $data = null;
     if ($storage) {
         $cache = $storage->getCache($internalPath);
         $data = $cache->get($internalPath);
         $watcher = $storage->getWatcher($internalPath);
         // if the file is not in the cache or needs to be updated, trigger the scanner and reload the data
         if (!$data) {
             if (!$storage->file_exists($internalPath)) {
                 return false;
             }
             $scanner = $storage->getScanner($internalPath);
             $scanner->scan($internalPath, Cache\Scanner::SCAN_SHALLOW);
             $data = $cache->get($internalPath);
         } else {
             if (!Cache\Scanner::isPartialFile($internalPath) && $watcher->checkUpdate($internalPath, $data)) {
                 $this->updater->propagate($path);
                 $data = $cache->get($internalPath);
             }
         }
         if ($data and isset($data['fileid'])) {
             // upgrades from oc6 or lower might not have the permissions set in the file cache
             if ($data['permissions'] === 0) {
                 $data['permissions'] = $storage->getPermissions($data['path']);
                 $cache->update($data['fileid'], array('permissions' => $data['permissions']));
             }
             if ($includeMountPoints and $data['mimetype'] === 'httpd/unix-directory') {
                 //add the sizes of other mount points to the folder
                 $extOnly = $includeMountPoints === 'ext';
                 $mountPoints = Filesystem::getMountPoints($path);
                 foreach ($mountPoints as $mountPoint) {
                     $subStorage = Filesystem::getStorage($mountPoint);
                     if ($subStorage) {
                         // exclude shared storage ?
                         if ($extOnly && $subStorage instanceof \OC\Files\Storage\Shared) {
                             continue;
                         }
                         $subCache = $subStorage->getCache('');
                         $rootEntry = $subCache->get('');
                         $data['size'] += isset($rootEntry['size']) ? $rootEntry['size'] : 0;
                     }
                 }
             }
         }
     }
     if (!$data) {
         return false;
     }
     if ($mount instanceof MoveableMount && $internalPath === '') {
         $data['permissions'] |= \OCP\Constants::PERMISSION_DELETE;
     }
     return new FileInfo($path, $storage, $internalPath, $data, $mount);
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:75,代码来源:view.php

示例2: getUnindexed

    /**
     * get the list of all unindexed files for the user
     *
     * @return array
     */
    public function getUnindexed()
    {
        $files = array();
        //TODO use server api for mounts & root
        $absoluteRoot = Filesystem::getView()->getAbsolutePath('/');
        $mounts = Filesystem::getMountPoints($absoluteRoot);
        $mount = Filesystem::getMountPoint($absoluteRoot);
        if (!in_array($mount, $mounts)) {
            $mounts[] = $mount;
        }
        $query = $this->db->prepareQuery('
			SELECT `*PREFIX*filecache`.`fileid`
			FROM `*PREFIX*filecache`
			LEFT JOIN `' . $this->tableName . '`
			ON `*PREFIX*filecache`.`fileid` = `' . $this->tableName . '`.`fileid`
			WHERE `storage` = ?
			AND ( `status` IS NULL OR `status` = ? )
			AND `path` LIKE \'files/%\'
		');
        foreach ($mounts as $mount) {
            if (is_string($mount)) {
                $storage = Filesystem::getStorage($mount);
            } else {
                if ($mount instanceof Mount) {
                    $storage = $mount->getStorage();
                } else {
                    $storage = null;
                    $this->logger->debug('expected string or instance of \\OC\\Files\\Mount\\Mount got ' . json_encode($mount));
                }
            }
            //only index local files for now
            if ($storage->isLocal()) {
                $cache = $storage->getCache();
                $numericId = $cache->getNumericStorageId();
                $result = $query->execute(array($numericId, Status::STATUS_NEW));
                while ($row = $result->fetchRow()) {
                    $files[] = $row['fileid'];
                }
            }
        }
        return $files;
    }
开发者ID:ntvis,项目名称:search_lucene,代码行数:47,代码来源:statusmapper.php

示例3: searchCommon

 /**
  * @param string $query
  * @param string $method
  * @return FileInfo[]
  */
 private function searchCommon($query, $method)
 {
     $files = array();
     $rootLength = strlen($this->fakeRoot);
     $mountPoint = Filesystem::getMountPoint($this->fakeRoot);
     $storage = Filesystem::getStorage($mountPoint);
     if ($storage) {
         $cache = $storage->getCache('');
         $results = $cache->{$method}($query);
         foreach ($results as $result) {
             if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') {
                 $internalPath = $result['path'];
                 $path = $mountPoint . $result['path'];
                 $result['path'] = substr($mountPoint . $result['path'], $rootLength);
                 $files[] = new FileInfo($path, $storage, $internalPath, $result);
             }
         }
         $mountPoints = Filesystem::getMountPoints($this->fakeRoot);
         foreach ($mountPoints as $mountPoint) {
             $storage = Filesystem::getStorage($mountPoint);
             if ($storage) {
                 $cache = $storage->getCache('');
                 $relativeMountPoint = substr($mountPoint, $rootLength);
                 $results = $cache->{$method}($query);
                 if ($results) {
                     foreach ($results as $result) {
                         $internalPath = $result['path'];
                         $result['path'] = rtrim($relativeMountPoint . $result['path'], '/');
                         $path = rtrim($mountPoint . $internalPath, '/');
                         $files[] = new FileInfo($path, $storage, $internalPath, $result);
                     }
                 }
             }
         }
     }
     return $files;
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:42,代码来源:view.php

示例4: getUnindexed

    /**
     * get the list of all unindexed files for the user
     *
     * @return array
     */
    public static function getUnindexed()
    {
        $files = array();
        $absoluteRoot = Filesystem::getView()->getAbsolutePath('/');
        $mounts = Filesystem::getMountPoints($absoluteRoot);
        $mount = Filesystem::getMountPoint($absoluteRoot);
        if (!in_array($mount, $mounts)) {
            $mounts[] = $mount;
        }
        $query = \OC_DB::prepare('
			SELECT `*PREFIX*filecache`.`fileid`
			FROM `*PREFIX*filecache`
			LEFT JOIN `*PREFIX*lucene_status`
			ON `*PREFIX*filecache`.`fileid` = `*PREFIX*lucene_status`.`fileid`
			WHERE `storage` = ?
			AND `status` IS NULL OR `status` = ?
		');
        foreach ($mounts as $mount) {
            if (is_string($mount)) {
                $storage = Filesystem::getStorage($mount);
            } else {
                if ($mount instanceof \OC\Files\Mount\Mount) {
                    $storage = $mount->getStorage();
                } else {
                    $storage = null;
                    Util::writeLog('search_lucene', 'expected string or instance of \\OC\\Files\\Mount\\Mount got ' . json_encode($mount), Util::DEBUG);
                }
            }
            //only index local files for now
            if ($storage instanceof \OC\Files\Storage\Local) {
                $cache = $storage->getCache();
                $numericId = $cache->getNumericStorageId();
                $result = $query->execute(array($numericId, 'N'));
                if (\OC_DB::isError($result)) {
                    Util::writeLog('search_lucene', 'failed to find unindexed files: ' . \OC_DB::getErrorMessage($result), Util::WARN);
                    return false;
                }
                while ($row = $result->fetchRow()) {
                    $files[] = $row['fileid'];
                }
            }
        }
        return $files;
    }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:49,代码来源:indexer.php

示例5: json_decode

        $users = json_decode($_GET['users']);
    }
} else {
    $users = array(OC_User::getUser());
}
$eventSource = new OC_EventSource();
ScanListener::$eventSource = $eventSource;
ScanListener::$view = \OC\Files\Filesystem::getView();
OC_Hook::connect('\\OC\\Files\\Cache\\Scanner', 'scan_folder', 'ScanListener', 'folder');
OC_Hook::connect('\\OC\\Files\\Cache\\Scanner', 'scan_file', 'ScanListener', 'file');
foreach ($users as $user) {
    $eventSource->send('user', $user);
    OC_Util::tearDownFS();
    OC_Util::setupFS($user);
    $absolutePath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir);
    $mountPoints = \OC\Files\Filesystem::getMountPoints($absolutePath);
    $mountPoints[] = \OC\Files\Filesystem::getMountPoint($absolutePath);
    $mountPoints = array_reverse($mountPoints);
    //start with the mount point of $dir
    foreach ($mountPoints as $mountPoint) {
        $storage = \OC\Files\Filesystem::getStorage($mountPoint);
        if ($storage) {
            ScanListener::$mountPoints[$storage->getId()] = $mountPoint;
            $scanner = $storage->getScanner();
            if ($force) {
                $scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG);
            } else {
                $scanner->backgroundScan();
            }
        }
    }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:scan.php


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