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


PHP DirectoryIterator::getExtension方法代码示例

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


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

示例1: getDirInfo

 * @param null
 */
spl_autoload_register(function ($class) {
    $Dir = str_replace('\\', '/', $class) . '.class.php';
    $FileName = __DIR__ . '/' . $Dir;
    #realpath('./'.$Dir)亦可 但调用了函数肯定会适度加重负担;
    include $FileName;
});
#Function文件夹中的文件自动加载
$FunctionDir = __DIR__ . '/Function/';
if (is_dir($FunctionDir)) {
    $iterator = new DirectoryIterator($FunctionDir);
    while ($iterator->valid()) {
        if ($iterator->isFile()) {
            $FileDir = $FunctionDir . $iterator->getFilename();
            if ($iterator->getExtension() == 'php') {
                include $FileDir;
            }
        }
        $iterator->next();
    }
}
#文件结构迭代器
function getDirInfo($dir)
{
    $iterator = new DirectoryIterator($dir);
    #先输出文件夹
    while ($iterator->valid()) {
        if ($iterator->isDir() && $iterator->getFilename() != '.' && $iterator->getFilename() != '..' && $iterator->getFilename() != '.git') {
            echo '<li class="flist filedir"><i class="fa fa-folder-open"></i> ' . $iterator->getFilename();
            echo '<ul class="dirlist">';
开发者ID:jjonline,项目名称:php-library,代码行数:31,代码来源:demo.php

示例2: getExtension

 public function getExtension()
 {
     if (method_exists(get_parent_class($this), 'getExtension')) {
         $ext = parent::getExtension();
     } else {
         $ext = pathinfo($this->getPathName(), PATHINFO_EXTENSION);
     }
     return strtolower($ext);
 }
开发者ID:pinoaffe,项目名称:cheryl,代码行数:9,代码来源:Cheryl.php

示例3: _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

示例4: getAllTxFiles

 /**
  * Retrieve all XLIFF for a given language.
  *
  * @param string $language The language to search the xliff files in.
  *
  * @return string[]
  */
 protected function getAllTxFiles($language)
 {
     $iterator = new \DirectoryIterator($this->txlang . DIRECTORY_SEPARATOR . $language);
     $files = array();
     while ($iterator->valid()) {
         if (!$iterator->isDot() && $iterator->isFile() && $iterator->getExtension() == 'xlf' && $this->isNotFileToSkip($iterator->getPathname())) {
             $files[$iterator->getPathname()] = $iterator->getFilename();
         }
         $iterator->next();
     }
     return $files;
 }
开发者ID:cyberspectrum,项目名称:contao-toolbox,代码行数:19,代码来源:TransifexBase.php

示例5: getDefaultLocale

 /**
  * Get system I18n files
  *
  * @return void
  */
 public function getDefaultLocale()
 {
     $localeFiles = new \DirectoryIterator(PATH_SYS . DIRECTORY_SEPARATOR . 'I18n');
     // Traverse the I18n directory and load each locale files
     while ($localeFiles->valid()) {
         if ($localeFiles->getExtension() == 'yml') {
             list($locale, $extension) = explode('.', $localeFiles->getFilename());
             if ($locale = self::validateLocale($locale)) {
                 $localeArray = Yaml::parse($localeFiles->getPathname());
                 $this->lang->set($locale, $localeArray);
             }
         }
         $localeFiles->next();
     }
 }
开发者ID:nurcahyo,项目名称:juriya,代码行数:20,代码来源:I18n.php

示例6: getLocale

 /**
  * @param  \DirectoryIterator $currentItem
  *
  * @return string
  */
 protected function getLocale(\DirectoryIterator $currentItem)
 {
     return substr($currentItem->getFilename(), 0, (strlen($currentItem->getExtension()) + 1) * -1);
 }
开发者ID:jpcercal,项目名称:silex-translation-provider,代码行数:9,代码来源:TranslationServiceProvider.php


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