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


PHP DirectoryIterator::seek方法代码示例

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


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

示例1: scanFolder

 protected function scanFolder($folder, &$position, $forFolders = true, $threshold_key = 'dir', $threshold_default = 50)
 {
     $registry = AEFactory::getConfiguration();
     // Initialize variables
     $arr = array();
     $false = false;
     if (!is_dir($folder) && !is_dir($folder . '/')) {
         return $false;
     }
     try {
         $di = new DirectoryIterator($folder);
     } catch (Exception $e) {
         $this->setWarning('Unreadable directory ' . $folder);
         return $false;
     }
     if (!$di->valid()) {
         $this->setWarning('Unreadable directory ' . $folder);
         return $false;
     }
     if (!empty($position)) {
         $di->seek($position);
         if ($di->key() != $position) {
             $position = null;
             return $arr;
         }
     }
     $counter = 0;
     $maxCounter = $registry->get("engine.scan.large.{$threshold_key}_threshold", $threshold_default);
     while ($di->valid()) {
         if ($di->isDot()) {
             $di->next();
             continue;
         }
         if ($di->isDir() != $forFolders) {
             $di->next();
             continue;
         }
         $ds = $folder == '' || $folder == '/' || @substr($folder, -1) == '/' || @substr($folder, -1) == DIRECTORY_SEPARATOR ? '' : DIRECTORY_SEPARATOR;
         $dir = $folder . $ds . $di->getFilename();
         $data = _AKEEBA_IS_WINDOWS ? AEUtilFilesystem::TranslateWinPath($dir) : $dir;
         if ($data) {
             $counter++;
             $arr[] = $data;
         }
         if ($counter == $maxCounter) {
             break;
         } else {
             $di->next();
         }
     }
     // Determine the new value for the position
     $di->next();
     if ($di->valid()) {
         $position = $di->key() - 1;
     } else {
         $position = null;
     }
     return $arr;
 }
开发者ID:WineWorld,项目名称:joomlatrialcmbg,代码行数:59,代码来源:large.php

示例2: _filestackProcessDir

 private function _filestackProcessDir($dir)
 {
     $Iterator = new \DirectoryIterator($dir);
     if ($this->_filestackKey > 0) {
         $Iterator->seek($this->_filestackKey);
     }
     while ($Iterator->valid()) {
         // timeout check:
         if ($this->intervalLimitIsReached() === true) {
             $this->_Dirstack->save();
             $this->_Filestack->save();
             $this->setMessage('Filestack creation: ' . $this->_filesInStack . ' files processed.');
             return false;
         }
         $this->_filestackKey = $Iterator->key();
         $this->Storage->set('filestackKey', $this->_filestackKey, 'filecheck');
         // skip dots:
         if ($Iterator->isDot()) {
             $Iterator->next();
             continue;
         }
         // if is directory save to database for later processing:
         $currentPath = $Iterator->getPathname();
         if ($Iterator->isDir()) {
             $this->_Dirstack->addPath($currentPath);
             $Iterator->next();
             continue;
         }
         // filesize check:
         $filesize = $Iterator->getSize();
         if (empty($filesize) || $filesize > $this->sizeFilter) {
             $Iterator->next();
             continue;
         }
         // filetype check:
         if ($this->_extensionCheck === true) {
             $fileExtension = $Iterator->getExtension();
             if (empty($fileExtension) || !isset($this->_allowedExtensions[$fileExtension])) {
                 $Iterator->next();
                 continue;
             }
         }
         // add file to stack:
         $this->_Filestack->addPath($currentPath);
         // create hash (if not yet done):
         if ($this->_createFilehashDb === true) {
             $pathhash = sha1($currentPath);
             $filehash = sha1_file($currentPath);
             $this->Database->setQuery("INSERT IGNORE INTO #__wm_filehashes (pathhash, filehash, mode) VALUES(" . $this->Database->q($pathhash) . "," . $this->Database->q($filehash) . ", " . $this->Database->q($this->runMode) . ")")->execute();
         }
         $this->_filesInStack++;
         $this->Storage->set('filesInStack', $this->_filesInStack, 'filecheck');
         $Iterator->next();
     }
     unset($Iterator);
     // current dir completed -> delete from stack:
     $this->_Dirstack->save();
     $this->_Dirstack->clear();
     $this->_Filestack->save();
     $this->_Filestack->clear();
     $this->Database->setQuery("DELETE FROM #__wm_dirstack WHERE path = " . $this->Database->q($dir) . "AND mode = " . $this->Database->q($this->runMode))->execute();
     $this->_filestackKey = 0;
     // select next dir from stack:
     $this->Database->setQuery("SELECT path FROM #__wm_dirstack WHERE mode = " . $this->Database->q($this->runMode) . " LIMIT 1")->execute();
     $row = $this->Database->getRow();
     if (empty($row)) {
         return true;
     }
     $this->_filestackPath = $row->path;
     $this->Storage->set('filestackPath', $this->_filestackPath, 'filecheck');
     return $this->_filestackProcessDir($row->path);
 }
开发者ID:ProjectArmy,项目名称:wp_wemahu,代码行数:72,代码来源:class.audit_filecheck.php

示例3: getAvailableFiles

 /**
  * Get list of files for file browser
  * @param int $seek
  * @param int $limit
  * @param string $filter
  * @param bool $secure use secure folder instead of repository root
  * @return array
  */
 public function getAvailableFiles($seek, $limit, $filter, $filterExtensions, $secure = false, $subdir = null)
 {
     $answer = array();
     if ($subdir && substr($subdir, -1) != '/') {
         $subdir .= '/';
     }
     $repositoryDir = $this->getPath($secure, $subdir);
     $iterator = new \DirectoryIterator($repositoryDir);
     $iterator->seek($seek);
     while ($iterator->valid() && count($answer) < $limit) {
         if ($iterator->isFile()) {
             $fileData = $this->getFileData($iterator->getFilename(), $secure, $subdir);
             $append = null;
             switch ($filter) {
                 case 'image':
                     if (in_array($fileData['ext'], $this->supportedImageExtensions)) {
                         $append = $fileData;
                     }
                     break;
                 default:
                     $append = $fileData;
                     break;
             }
             if ($filterExtensions && !in_array($fileData['ext'], $filterExtensions)) {
                 $append = null;
             }
             if ($append) {
                 $answer[] = $append;
             }
         }
         $iterator->next();
     }
     return $answer;
 }
开发者ID:impresspages,项目名称:impresspages,代码行数:42,代码来源:BrowserModel.php

示例4: DirectoryIterator

<?php

$di = new DirectoryIterator(__DIR__);
$di->seek(2);
$n = 0;
while ($di->valid()) {
    $n++;
    $di->next();
}
echo "With seek(2) we get {$n}\n";
$di->seek(0);
$m = 0;
while ($di->valid()) {
    $m++;
    $di->next();
}
echo "With seek(0) we get {$m}\n";
$o = 0;
$di->rewind();
while ($di->valid()) {
    $o++;
    $di->next();
}
echo "Without seek we get {$o}\n";
$p = 0;
$di->seek($o + 1);
while ($di->valid()) {
    $p++;
    $di->next();
}
var_dump($n !== $m, $m === $o, $p === 0);
开发者ID:clifton98,项目名称:hhvm,代码行数:31,代码来源:dit_006.php

示例5: DirectoryIterator

<?php

mkdir(__DIR__ . DIRECTORY_SEPARATOR . 'tmp');
touch(__DIR__ . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'a');
touch(__DIR__ . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . 'b');
$d = new DirectoryIterator(__DIR__ . DIRECTORY_SEPARATOR . 'tmp');
$d->seek(0);
$path0 = $d->current()->getPathname();
$d->seek(1);
$path1 = $d->current()->getPathname();
$d->seek(2);
$path2 = $d->current()->getPathname();
$d->seek(0);
var_dump($path0 === $d->current()->getPathname());
$d->seek(1);
var_dump($path1 === $d->current()->getPathname());
$d->seek(2);
var_dump($path2 === $d->current()->getPathname());
$d->seek(0);
var_dump($path0 === $d->current()->getPathname());
开发者ID:gleamingthecube,项目名称:php,代码行数:20,代码来源:ext_spl_tests_bug68557.php

示例6: DirectoryIterator

<?php

$dir = new DirectoryIterator('./images');
session_start();
if (!isset($_SESSION['imageid'])) {
    $_SESSION['imageid'] = 0;
}
$dir->seek($_SESSION['imageid']);
do {
    $dir->next();
    //loop back to 0
    if (!$dir->valid()) {
        $dir->seek(0);
    }
} while (!$dir->isFile() || !$dir->valid() || !exif_imagetype($dir->getPathname()));
//it's not an image
$_SESSION['imageid'] = $dir->key();
//echo $dir->key();
echo './images/' . $dir->getFilename();
//imagejpeg('./images/'.$fileinfo-getFilename(), NULL,100);
开发者ID:WMTU,项目名称:DJDisplayBoard,代码行数:20,代码来源:images.php

示例7: seek

 /**
  * Overridden to not crash PHP 5.2, because DirectoryIterator::seek was added in 5.3.
  *
  * @link http://lxr.php.net/xref/PHP_5_3/ext/spl/spl_directory.c#807
  */
 public function seek($position)
 {
     if (is_callable(array('parent', 'seek'))) {
         parent::seek($position);
         return;
     }
     if ($this->key() > $position) {
         $this->rewind();
     }
     while ($this->key() < $position) {
         if (!$this->valid()) {
             return;
         }
         $this->next();
     }
 }
开发者ID:onedaylabs,项目名称:onedaylabs.com,代码行数:21,代码来源:FilesystemIterator.php

示例8: DirectoryIterator

<?php

$dit = new DirectoryIterator(__DIR__);
$dit->seek(5);
echo $dit->key(), PHP_EOL;
$dit->seek(4);
echo $dit->key(), PHP_EOL;
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:DirectoryIterator_seek.php


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