本文整理汇总了PHP中RecursiveDirectoryIterator::isDir方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveDirectoryIterator::isDir方法的具体用法?PHP RecursiveDirectoryIterator::isDir怎么用?PHP RecursiveDirectoryIterator::isDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecursiveDirectoryIterator
的用法示例。
在下文中一共展示了RecursiveDirectoryIterator::isDir方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: _recurseDirectory
/**
* Recursive directory function.
*
* @param RecursiveDirectoryIterator $iterator
*/
protected function _recurseDirectory($iterator)
{
while ($iterator->valid()) {
if ($iterator->isDir() && !$iterator->isDot()) {
if ($iterator->hasChildren()) {
$this->_recurseDirectory($iterator->getChildren());
}
} elseif ($iterator->isFile()) {
$path = $iterator->getPath() . '/' . $iterator->getFilename();
$pathinfo = pathinfo($path);
if ($this->_isPhpFile($path)) {
$this->addFile($path);
}
}
$iterator->next();
}
}
示例3: json_encode
<?php
$folder = $_POST['path'];
$flags = FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS;
$d_iterator = new RecursiveDirectoryIterator($folder, $flags);
$directories = array();
foreach ($d_iterator as $file) {
if ($d_iterator->isDir()) {
$directories[] = $d_iterator->getFileName();
}
}
echo json_encode($directories);
示例4: array
$xmlForms = array("form" => array(), "resource" => array());
if ($info->isDir()) {
$iterator = new RecursiveDirectoryIterator($formImportDir);
while ($iterator->valid()) {
if ($iterator->isFile()) {
$ext = pathinfo($iterator->getPathname(), PATHINFO_EXTENSION);
if ($ext == "xml") {
// echo $prefix,$j," import ",$dirIterator->getPathname(), "<br>\n";
$xmlForms["form"][$iterator->getFilename()] = $iterator->getPathname();
} else {
$filepath = preg_replace("/" . preg_replace("/\\//", "\\\\/", HEURIST_UPLOAD_DIR) . "/", "/", $iterator->getPathname());
// echo $prefix,$j," resource ".$dirIterator->getFilename()." has path ".$filepath, "<br>\n";
$xmlForms["resource"][$iterator->getFilename()] = $filepath;
}
} else {
if ($iterator->isDir() && $iterator->hasChildren(false)) {
// echo $i,pathinfo($iterator->getPathname(),PATHINFO_FILENAME), "<br>\n";
processChildDir($iterator->getChildren(), $i . "-");
}
}
$iterator->next();
$i++;
}
} else {
echo "something is wrong";
}
foreach ($xmlForms["form"] as $filename => $path) {
list($rtyName, $headers, $row) = parseImportForm($filename, $xmlForms["resource"]);
$rtyName = "" . $rtyName;
if (!$rtyName) {
continue;
示例5: _fetch
/**
*
* Recursively iterates through a directory looking for class files.
*
* Skips CVS directories, and all files and dirs not starting with
* a capital letter (such as dot-files).
*
* @param RecursiveDirectoryIterator $iter Directory iterator.
*
* @return void
*
*/
protected function _fetch(RecursiveDirectoryIterator $iter)
{
for ($iter->rewind(); $iter->valid(); $iter->next()) {
// preliminaries
$path = $iter->current()->getPathname();
$file = basename($path);
$capital = ctype_alpha($file[0]) && $file == ucfirst($file);
$phpfile = strripos($file, '.php');
// check for valid class files
if ($iter->isDot() || !$capital) {
// skip dot-files (including dot-file directories), as
// well as files/dirs not starting with a capital letter
continue;
} elseif ($iter->isDir() && $file == 'CVS') {
// skip CVS directories
continue;
} elseif ($iter->isDir() && $iter->hasChildren()) {
// descend into child directories
$this->_fetch($iter->getChildren());
} elseif ($iter->isFile() && $phpfile) {
// map the .php file to a class name
$len = strlen($this->_base);
$class = substr($path, $len, -4);
// drops .php
$class = str_replace(DIRECTORY_SEPARATOR, '_', $class);
$this->_map[$class] = $path;
}
}
}
示例6: valid
function valid()
{
if (parent::valid()) {
if (!parent::isDir() || parent::isDot()) {
parent::next();
return $this->valid();
}
return TRUE;
}
return FALSE;
}
示例7: delete
/**
* Force deletion on a cached resource.
*
* @param {string} $key Identifier of target cache.
* @param {?string} $hash Target revision to delete, all revisions will be deleted if omitted.
*/
public static function delete($key, $hash = '*')
{
$res = self::resolve($key, $hash);
// Skip the delete if nothing is found.
if ($res === null) {
return;
}
if ($res->isFile()) {
// Remove target revision(s).
if (!$res->isWritable()) {
Log::warning('Target file is not writable, deletion skipped.');
} else {
$path = $res->getRealPath();
unlink($path);
$path = dirname($path);
// Remove the directory if empty.
$res = new \RecursiveDirectoryIterator($path, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS);
if ($res->isDir() && !$res->hasChildren()) {
rmdir($path);
}
}
} else {
if ($res->isDir()) {
$cacheDirectory = $res->getRealPath();
foreach ($res as $file) {
if ($file->isFile()) {
unlink($file->getRealPath());
} else {
if ($file->isDir()) {
rmdir($file->getRealPath());
}
}
}
rmdir($cacheDirectory);
}
}
}