本文整理汇总了PHP中RecursiveDirectoryIterator::next方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveDirectoryIterator::next方法的具体用法?PHP RecursiveDirectoryIterator::next怎么用?PHP RecursiveDirectoryIterator::next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecursiveDirectoryIterator
的用法示例。
在下文中一共展示了RecursiveDirectoryIterator::next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: next
public function next()
{
parent::next();
while ($this->isDot()) {
parent::next();
}
}
示例2: rewind
public function rewind()
{
if (false === $this->isRewindable()) {
return;
}
parent::next();
parent::rewind();
}
示例3: rewind
/**
* Do nothing for non rewindable stream
*/
public function rewind()
{
if (false === $this->isRewindable()) {
return;
}
// @see https://bugs.php.net/bug.php?id=49104
parent::next();
parent::rewind();
}
示例4: rewind
public function rewind()
{
if (false === $this->isRewindable()) {
return;
}
if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) {
parent::next();
}
parent::rewind();
}
示例5: valid
/**
* Returns true if file is valid.
* Valid Files: Directories and Files not beginning with a "." (dot).
*
* @todo make it more flexible to handle hidden dirs on demand etc,
* win/*nix compat
*
* @return boolean if current file entry is vali
*/
public function valid()
{
if (parent::valid()) {
if (parent::isDot() || parent::isDir() && strpos(parent::getFilename(), '.') === 0) {
parent::next();
// zum nächsten eintrag hüpfen
return $this->valid();
// nochmal prüfen
}
return true;
}
return false;
}
开发者ID:joshiausdemwald,项目名称:sfFilebasePlugin,代码行数:22,代码来源:sfFilebasePluginRecursiveDirectoryIterator.php
示例6: _deleteFolder
/**
* deletes a folder recursively
*
* @param string $path the folder to delete
*
* @since 1.0
*/
protected static function _deleteFolder($path)
{
/**
* @var \SplFileInfo $item
*/
$dir = new \RecursiveDirectoryIterator($path);
while ($dir->valid()) {
$item = $dir->current();
if (!in_array($item->getFilename(), array('.', '..'))) {
$isFile = $item->isFile();
$isFile ? unlink($item->getRealPath()) : self::_deleteFolder($item->getRealPath());
}
$dir->next();
}
rmdir($path);
}
示例7: load_tests
private function load_tests(RecursiveDirectoryIterator $dir)
{
while ($dir->valid()) {
$current = $dir->current();
if ($dir->isFile() && preg_match("/(.)Test\\.php\$/", $current->getFilename(), $matches)) {
// XXX: handle errors
include $current->getPathname();
$x = explode('.', $current->getFilename());
$class = $x[0];
$rclass = new ReflectionClass($class);
if ($rclass->getParentClass()->getName() == 'UnitTest') {
$this->cases[] = $rclass;
}
} elseif ($dir->hasChildren() && preg_match("/^\\./", $current->getFilename(), $matches) == 0) {
$this->load_tests($dir->getChildren());
}
$dir->next();
}
}
示例8: scanDirectory
/**
* @param $identifier
* @param bool $files
* @param bool $folders
* @param bool $recursive
* @return array
*/
public function scanDirectory($identifier, $files = true, $folders = true, $recursive = false)
{
$directoryEntries = [];
$iterator = new \RecursiveDirectoryIterator($this->sftpWrapper . $identifier, $this->iteratorFlags);
while ($iterator->valid()) {
/** @var $entry \SplFileInfo */
$entry = $iterator->current();
$identifier = substr($entry->getPathname(), $this->sftpWrapperLength);
if ($files && $entry->isFile()) {
$directoryEntries[$identifier] = $this->getShortInfo($identifier, 'file');
} elseif ($folders && $entry->isDir()) {
$directoryEntries[$identifier] = $this->getShortInfo($identifier, 'dir');
}
$iterator->next();
}
if ($recursive) {
foreach ($directoryEntries as $directoryEntry) {
if ($directoryEntry['type'] === 'dir') {
$scanResults = $this->scanDirectory($directoryEntry['identifier'], $files, $folders, $recursive);
foreach ($scanResults as $identifier => $info) {
$directoryEntries[$identifier] = $info;
}
}
}
}
return $directoryEntries;
}
示例9: skipdots
protected function skipdots()
{
while ($this->isDot()) {
parent::next();
}
}
示例10: getFileAndFoldernamesInPath
/**
* Returns a list with the names of all files and folders in a path, optionally recursive.
* Folder names have a trailing slash.
*
* @param string $path The absolute path
* @param bool $recursive If TRUE, recursively fetches files and folders
* @return array
*/
protected function getFileAndFoldernamesInPath($path, $recursive = FALSE)
{
if ($recursive) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::CURRENT_AS_FILEINFO));
} else {
$iterator = new \RecursiveDirectoryIterator($path, \FilesystemIterator::CURRENT_AS_FILEINFO);
}
$directoryEntries = array();
while ($iterator->valid()) {
/** @var $entry \SplFileInfo */
$entry = $iterator->current();
// skip non-files/non-folders, and empty entries
if (!$entry->isFile() && !$entry->isDir() || $entry->getFilename() == '') {
$iterator->next();
continue;
}
// skip the pseudo-directories "." and ".."
if ($entry->getFilename() == '..' || $entry->getFilename() == '.') {
$iterator->next();
continue;
}
$entryPath = GeneralUtility::fixWindowsFilePath(substr($entry->getPathname(), strlen($path)));
if ($entry->isDir()) {
$entryPath .= '/';
}
$directoryEntries[] = $entryPath;
$iterator->next();
}
return $directoryEntries;
}
示例11: retrieveFileAndFoldersInPath
/**
* Returns a list with the names of all files and folders in a path, optionally recursive.
*
* @param string $path The absolute path
* @param bool $recursive If TRUE, recursively fetches files and folders
* @param bool $includeFiles
* @param bool $includeDirs
* @param string $sort Property name used to sort the items.
* Among them may be: '' (empty, no sorting), name,
* fileext, size, tstamp and rw.
* If a driver does not support the given property, it
* should fall back to "name".
* @param bool $sortRev TRUE to indicate reverse sorting (last to first)
* @return array
*/
protected function retrieveFileAndFoldersInPath($path, $recursive = false, $includeFiles = true, $includeDirs = true, $sort = '', $sortRev = false)
{
$pathLength = strlen($this->getAbsoluteBasePath());
$iteratorMode = \FilesystemIterator::UNIX_PATHS | \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::FOLLOW_SYMLINKS;
if ($recursive) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, $iteratorMode), \RecursiveIteratorIterator::SELF_FIRST);
} else {
$iterator = new \RecursiveDirectoryIterator($path, $iteratorMode);
}
$directoryEntries = array();
while ($iterator->valid()) {
/** @var $entry \SplFileInfo */
$entry = $iterator->current();
// skip non-files/non-folders, and empty entries
if (!$entry->isFile() && !$entry->isDir() || $entry->getFilename() == '' || $entry->isFile() && !$includeFiles || $entry->isDir() && !$includeDirs) {
$iterator->next();
continue;
}
$entryIdentifier = '/' . substr($entry->getPathname(), $pathLength);
$entryName = PathUtility::basename($entryIdentifier);
if ($entry->isDir()) {
$entryIdentifier .= '/';
}
$entryArray = array('identifier' => $entryIdentifier, 'name' => $entryName, 'type' => $entry->isDir() ? 'dir' : 'file');
$directoryEntries[$entryIdentifier] = $entryArray;
$iterator->next();
}
return $this->sortDirectoryEntries($directoryEntries, $sort, $sortRev);
}
示例12: valid
function valid()
{
if (parent::valid()) {
if (!parent::isDir() || parent::isDot()) {
parent::next();
return $this->valid();
}
return TRUE;
}
return FALSE;
}
示例13: testBz2Create
/**
* test create BZ2 file
*
* @since 1.0
*/
public function testBz2Create()
{
/**
* @var \SplFileInfo $item
*/
$file = $this->path . 'test.bz2';
$filesPath = $this->path . 'files' . DS;
$creator = new Creator($file);
$dir = new \RecursiveDirectoryIterator($filesPath);
while ($dir->valid()) {
$item = $dir->current();
if ($item->isFile()) {
$add = $creator->addFile($item->getRealPath(), $item->getFilename());
$this->assertTrue($add, sprintf('the file %s was not added to the tar file', $item->getFilename()));
}
$dir->next();
}
$this->assertFileExists($file);
$this->assertEquals(10, $creator->getFilesCount());
}
示例14: resolve
/**
* @private
*
* 1. Mimics tmp directory
* 2. Find latest cache if $hash is null
* 3. Return directory if $hash is '*'
*/
private static function resolve($key, $hash = null)
{
$target = sys_get_temp_dir();
if (strrpos($target, DIRECTORY_SEPARATOR) !== strlen($target) - 1) {
$target .= DIRECTORY_SEPARATOR;
}
$target .= md5($key);
if (!file_exists($target)) {
if ($hash !== '*') {
return null;
} elseif (mkdir($target) === false) {
throw new FrameworkException('Error creating cache folder "' . $target . '", please check folder permissions.');
}
} else {
if (is_file($target)) {
throw new FrameworkException($target . ' is already a file, please specify another path.');
}
}
$target .= DIRECTORY_SEPARATOR;
if ($hash === '*') {
return new \RecursiveDirectoryIterator($target, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS);
}
if ($hash !== null) {
$target = "{$target}{$hash}";
if (!is_file($target)) {
throw new FrameworkException('Target revision is not a file.');
}
return new \SplFileInfo($target);
} else {
$res = new \RecursiveDirectoryIterator($target, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS);
$res->next();
$res->rewind();
$lfile = null;
foreach ($res as $file) {
if ($file->isFile() && strlen($file->getFilename()) == 32 && ($lfile == null || $lfile->getMTime() < $file->getMTime())) {
$lfile = $file;
}
}
if ($lfile === null) {
return null;
}
if (!$lfile->isReadable() || !$lfile->isWritable()) {
throw new FrameworkException('Cache cannot be read or written, please check file permission to PHP user.');
}
return $lfile;
}
}
示例15: rewind
/**
* Do nothing for non rewindable stream.
*/
public function rewind()
{
if (false === $this->isRewindable()) {
return;
}
// @see https://bugs.php.net/68557
if (PHP_VERSION_ID < 50523 || PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50607) {
parent::next();
}
parent::rewind();
}