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


PHP DirectoryIterator::current方法代码示例

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


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

示例1: cleanDir

 protected function cleanDir($dir)
 {
     $files = new \DirectoryIterator($dir);
     while ($files->valid()) {
         if (in_array(substr($files->current(), -2), ['.0', '.1'])) {
             unlink($dir . '/' . $files->current());
         }
         $files->next();
     }
 }
开发者ID:vtk13,项目名称:word-counter,代码行数:10,代码来源:Parser.php

示例2: fromFileScan

 /**
  * @ignore
  */
 public static function fromFileScan($uPattern)
 {
     $tSep = quotemeta(DIRECTORY_SEPARATOR);
     $tPos = strrpos($uPattern, $tSep);
     if ($tSep !== '/' && $tPos === false) {
         $tSep = '/';
         $tPos = strrpos($uPattern, $tSep);
     }
     if ($tPos !== false) {
         $tPattern = substr($uPattern, $tPos + strlen($tSep));
         $tPath = substr($uPattern, 0, $tPos + strlen($tSep));
     } else {
         $tPath = $uPattern;
         $tPattern = "";
     }
     $tTemp = new static();
     $tHandle = new \DirectoryIterator($tPath);
     $tPatExists = strlen($uPattern) > 0;
     for (; $tHandle->valid(); $tHandle->next()) {
         if (!$tHandle->isFile()) {
             continue;
         }
         $tFile = $tHandle->current();
         if ($tPatExists && !fnmatch($tPattern, $tFile)) {
             continue;
         }
         $tTemp->add(simplexml_load_file($tPath . $tFile));
     }
     return $tTemp;
 }
开发者ID:eserozvataf,项目名称:scabbia1,代码行数:33,代码来源:XmlCollection.php

示例3: current

 /**
  * Return the current resource.
  *
  * @return \com\mohiva\common\io\Resource The current `Resource` object or null if no resource
  * exists.
  */
 public function current()
 {
     if (!$this->valid()) {
         return null;
     }
     $resource = $this->getResourceLoader()->getResourceByType($this->iterator->current(), $this->resourceType);
     return $resource;
 }
开发者ID:mohiva,项目名称:common,代码行数:14,代码来源:FilesystemResourceContainer.php

示例4: rm_recursive

function rm_recursive($path)
{
    if (!is_dir($path)) {
        return;
    }
    $dir = new DirectoryIterator($path);
    while ($dir->valid()) {
        if (!$dir->isDot()) {
            if ($dir->isDir()) {
                rm_recursive($path . DIRECTORY_SEPARATOR . $dir->current());
            } else {
                unlink($path . DIRECTORY_SEPARATOR . $dir->current());
            }
        }
        $dir->next();
    }
    rmdir($path);
}
开发者ID:guoyu07,项目名称:NYAF,代码行数:18,代码来源:functable.php

示例5: current

 /**
  * Current.
  * Please, see \DirectoryIterator::current() method.
  *
  * @return  mixed
  */
 public function current()
 {
     $out = parent::current();
     if (null !== $this->_splFileInfoClass && $out instanceof \SplFileInfo) {
         $out->setInfoClass($this->_splFileInfoClass);
         $out = $out->getFileInfo();
         if ($out instanceof \Hoa\Iterator\SplFileInfo) {
             $out->setRelativePath($this->getRelativePath());
         }
     }
     return $out;
 }
开发者ID:Grummfy,项目名称:Central,代码行数:18,代码来源:Directory.php

示例6: DirectoryIterator

 function __construct($link)
 {
     $d = new DirectoryIterator($link);
     while ($d->valid()) {
         $file = $d->current();
         if (!$file->isDot()) {
             $this->files[] = $file->getFilename();
         }
         $d->next();
     }
     $this->path = $d->getPath();
 }
开发者ID:AzoteStark,项目名称:php-class-checkFolder,代码行数:12,代码来源:checkFolder.class.php

示例7: indexAction

 function indexAction()
 {
     setcookie("previewTemplateName", false, 0, "/");
     $templates = array();
     $dir = new DirectoryIterator(Config::get('TEMPLATES_PATH'));
     while ($dir->valid()) {
         if (!$dir->isDot()) {
             $templates[] = (string) $dir->current();
         }
         $dir->next();
     }
     $this->set("alltemplates", $templates);
 }
开发者ID:reinfire,项目名称:arfooo,代码行数:13,代码来源:TemplateController.php

示例8: getImages

 function getImages()
 {
     $filesInFolder = new DirectoryIterator($this->imagePath);
     $imageList = array();
     $i = 0;
     while ($filesInFolder->valid()) {
         $file = $filesInFolder->current();
         $filename = $file->getFilename();
         $src = "{$this->imagePath}/{$filename}";
         $fileInfo = new finfo(FILEINFO_MIME_TYPE);
         $mimeType = $fileInfo->file($src);
         if ($mimeType === "image/jpeg") {
             $imageList[$i++] = $src;
         }
         $filesInFolder->next();
     }
     return $imageList;
 }
开发者ID:arvin-tcm,项目名称:CS526_Web,代码行数:18,代码来源:ImageModel.php

示例9: showImages

function showImages()
{
    $out = "<h1>Image Gallery</h1>";
    $out .= "<ul id='images'>";
    $folder = "img";
    $filesInFolder = new DirectoryIterator($folder);
    while ($filesInFolder->valid()) {
        $file = $filesInFolder->current();
        $fileName = $file->getFileName();
        $src = "{$folder}/{$fileName}";
        $fileInfo = new Finfo(FILEINFO_MIME_TYPE);
        $mimeType = $fileInfo->file($src);
        if ($mimeType === 'image/jpeg') {
            $out .= "<li><img src='{$src}' /></li>";
        }
        $filesInFolder->next();
    }
    $out .= "</ul>";
    return $out;
}
开发者ID:vishalsanfran,项目名称:lamp-learn,代码行数:20,代码来源:gallery.php

示例10: WalkDirectory

 /**
  * the recursive function that walks through a directory of given path
  */
 protected function WalkDirectory(DirectoryIterator $Directory, $pRecursiveWalk, $depth = 0)
 {
     $this->mStringFolderTree = str_repeat('&nbsp;', $depth * 5) . $Directory->getPathName() . '<br />';
     while ($Directory->valid()) {
         $node = $Directory->current();
         if ($node->isDir() && $node->isReadable() && !$node->isDot()) {
             if ($this->FolderFilter($Directory, $node)) {
                 $this->ProcessFolder($Directory, $node);
             }
             if ($pRecursiveWalk) {
                 $this->mStringFolderTree .= $this->WalkDirectory(new DirectoryIterator($node->getPathname()), $pRecursiveWalk, $depth + 1);
             }
         } elseif ($node->isFile()) {
             if ($this->FileFilter($Directory, $node)) {
                 $this->ProcessFile($Directory, $node);
             }
             $this->mStringFolderTree .= str_repeat('&nbsp;', (1 + $depth) * 5) . $node->getFilename();
         }
         $Directory->next();
     }
     return $this->mStringFolderTree;
 }
开发者ID:rizaramadan,项目名称:folder-walking,代码行数:25,代码来源:FolderWalker.class.php

示例11: showImages

function showImages()
{
    $out = "<h1>Image Gallery</h1>";
    $out .= "<ul id='images'";
    $folder = "img";
    $filesInFolder = new DirectoryIterator($folder);
    //Iterate through the directory for images
    //with different file types
    while ($filesInFolder->valid()) {
        $file = $filesInFolder->current();
        $filename = $file->getFilename();
        $src = "{$folder}/{$filename}";
        $fileInfo = new Finfo(FILEINFO_MIME_TYPE);
        $mimeType = $fileInfo->file($src);
        if ($mimeType === 'image/jpeg' || $mimeType === 'image/pjpeg' || $mimeType === 'image/png' || $mimeType === 'image/gif') {
            $out .= "<li><img src='{$src}' /></li>";
        }
        $filesInFolder->next();
    }
    $out .= "</ul>";
    return $out;
}
开发者ID:jevy18,项目名称:image_gallery,代码行数:22,代码来源:gallery.php

示例12: WalkDirectory

function WalkDirectory(DirectoryIterator $iter, $depth = 0)
{
    $return = str_repeat(' ', $depth * 5) . $iter->getPathName() . "\n";
    while ($iter->valid()) {
        $node = $iter->current();
        if ($node->isDir() && $node->isReadable() && !$node->isDot()) {
            $return .= WalkDirectory(new DirectoryIterator($node->getPathname()), $depth + 1);
        } elseif ($node->isFile()) {
            $return .= str_repeat(' ', (1 + $depth) * 5) . $node->getFilename() . "\n";
        }
        // Rename wf_ to admin_
        $oldName = $node->getFilename();
        if (strpos($oldName, 'wf_') === 0) {
            $newFileName = str_replace('wf_', 'admin_', $node->getFilename());
            $path = str_replace('/www/wildflower/', '', $node->getPathname());
            $cmd = 'git mv ' . $path . ' ' . str_replace($oldName, $newFileName, $path) . "\n";
            $return .= $cmd;
            exec($cmd);
        }
        $iter->next();
    }
    return $return;
}
开发者ID:uuking,项目名称:wildflower,代码行数:23,代码来源:renameWfFiles.php

示例13: copyDirectory

 /**
  * Copy a directory within all its items.
  *
  * @param string $source  The source directory
  * @param string $target  The target to create
  * @param array  $exclude List of files / folders that should not be copyed
  *
  * @return void
  */
 public function copyDirectory($source, $target, $exclude = array())
 {
     // first check for target itself
     self::createDirectory($target);
     $iterator = new DirectoryIterator($source);
     while ($iterator->valid()) {
         $item = $iterator->current();
         // create new file
         if ($iterator->isFile()) {
             self::copyFile($source . '/' . $item, $target);
         }
         // create folder recursive
         if (!$iterator->isDot() && $iterator->isDir() && !in_array($item, $exclude)) {
             self::copyDirectory($source . '/' . $item, $target . '/' . $item);
         }
         $iterator->next();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:IOHelper.php

示例14: DirectoryIterator

<?php

$dir = new DirectoryIterator(__DIR__ . '/../../sample_dir');
$files = array();
// order changes per machine
while ($dir->valid()) {
    if (!$dir->isDot()) {
        $files[] = $dir->current() . "\n";
    }
    $dir->next();
}
asort($files);
var_dump(array_values($files));
开发者ID:badlamer,项目名称:hhvm,代码行数:13,代码来源:1799.php

示例15: _cleanUp

 /**
  * Cleanup the test directory output folder
  *
  * @param string $dir The directory to clean up
  *
  * @return void
  */
 protected function _cleanUp($dir)
 {
     $iterator = new DirectoryIterator($dir);
     while ($iterator->valid()) {
         // delete file
         if ($iterator->isFile()) {
             unlink($dir . '/' . $iterator->current());
         }
         // delete folder recursive
         if (!$iterator->isDot() && $iterator->isDir()) {
             $this->_cleanUp($dir . '/' . $iterator->current());
             rmdir($dir . '/' . $iterator->current());
         }
         $iterator->next();
     }
     unset($iterator);
 }
开发者ID:michaelyin1,项目名称:Modern-Toolkit,代码行数:24,代码来源:AbstractTests.php


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