本文整理汇总了PHP中DirectoryIterator::isFile方法的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryIterator::isFile方法的具体用法?PHP DirectoryIterator::isFile怎么用?PHP DirectoryIterator::isFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryIterator
的用法示例。
在下文中一共展示了DirectoryIterator::isFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logAction
public function logAction()
{
$pageSize = 4096;
$overlapSize = 128;
$dir = APPLICATION_PATH . '/../data/logs/';
$file = $this->_getParam('file', null);
$this->view->page = $this->_getParam('page', 0);
if ($file === null) {
$file = sprintf('%s_application.log', Zend_Date::now()->toString('yyyy.MM.dd'));
}
$fp = fopen($dir . $file, 'r');
fseek($fp, -$pageSize * ($this->view->page + 1) + $overlapSize, SEEK_END);
$this->view->errorLog = fread($fp, $pageSize + $overlapSize * 2);
fclose($fp);
$iterator = new DirectoryIterator($dir);
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if ($iterator->isFile()) {
$files[$iterator->getFilename()] = $iterator->getPathName();
}
}
$iterator->next();
}
$this->view->itemCountPerPage = $pageSize;
$this->view->totalItemCount = filesize($dir . $file);
$this->view->files = $files;
}
示例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;
}
示例3: findBy
/**
*
* @param Criterio $filtro
* @param string $order
* @param integer $limitOffset
* @param integer $limitCount
* @param string $group
* @return mixed Proyecto
*/
function findBy($filtro = null, $order = null, $limitOffset = null, $limitCount = null, $group = null)
{
$dir = new DirectoryIterator(DIR_PROYECTOS);
while ($dir->valid()) {
if ($dir->isFile() && stripos($dir->getFilename(), '.json')) {
$proyFilename = DIR_PROYECTOS . $dir->getFilename();
$p = new Proyecto();
$fp = fopen($proyFilename, 'r');
$strJsonProy = fread($fp, filesize($proyFilename));
fclose($fp);
$jsonProy = json_decode($strJsonProy);
$p->setNombre($jsonProy->nombre);
$p->setRuta($jsonProy->ruta);
$p->setTieneProyectoEcplipse(file_exists("{$jsonProy->ruta}/.project"));
if ($p->getTieneProyectoEclipse()) {
$eclipseProy = simplexml_load_file("{$jsonProy->ruta}/.project");
$p->setNombre((string) $eclipseProy->name);
}
$p->setId($jsonProy->id);
$p->setDbConfig($jsonProy->dbConfig);
$lista[] = $p;
}
$dir->next();
}
return $lista;
}
示例4: load
/**
* Carrega todos os arquivos do pacote especificado o carregamento considera o classpath atual da execusão
*
* @param string $package nome do pacote
*/
public static function load($package)
{
self::getCurrentPath();
if (substr($package, -1, 1) != "/") {
$package .= "/";
}
foreach (self::$classPath as $path) {
$dir = $path . $package;
if (is_dir($dir)) {
$d = new DirectoryIterator($dir);
while ($d->valid()) {
if ($d->isFile()) {
$requireThis = false;
//testa a extensão
foreach (self::$filesExtensions as $ext) {
if (substr($d->getFilename(), strlen($ext) * -1, strlen($ext)) == $ext) {
$requireThis = true;
break;
}
}
if ($requireThis) {
require_once $package . $d->getFilename();
}
}
$d->next();
}
}
}
}
示例5: valid
function valid()
{
if (parent::valid()) {
if (!parent::isFile()) {
parent::next();
return $this->valid();
}
return TRUE;
}
return FALSE;
}
示例6: valid
public function valid()
{
if (parent::valid()) {
if (!parent::isFile()) {
parent::next();
return $this->valid();
}
return True;
}
return False;
}
示例7: getTestFiles
function getTestFiles($dir = '')
{
$file = new DirectoryIterator($dir);
$res = array();
while ($file->valid()) {
if ($file->isFile() && substr($file->getPathName(), -8) == 'Test.php') {
$res[] = $file->getPathName();
}
$file->next();
}
return $res;
}
示例8: getTestFiles
function getTestFiles($dir = '')
{
$file = new DirectoryIterator($dir);
$res = array();
while ($file->valid()) {
if ($file->isFile() && substr($file->getPathName(), -4) == '.php') {
$class = str_replace(DIRECTORY_SEPARATOR, '_', substr($file->getPathName(), 0, -4));
$res[] = array($file->getPathName(), $class);
}
$file->next();
}
return $res;
}
示例9: pushItem
public function pushItem(&$listing, DirectoryIterator $item)
{
// dot would be for morse code locale?
if (!$item->isDot() && $item->isFile()) {
// explode and extract name & type
list($name, $type) = explode('.', $item->getFilename());
assert('!empty($name) && !empty($type); // invalid locale files');
// push name to stack
if ($type == 'yml') {
array_push($listing, $name);
}
}
}
示例10: indexAction
public function indexAction()
{
// Get path
$this->view->path = $path = $this->_getPath();
$this->view->relPath = $relPath = $this->_getRelPath($path);
// List files
$files = array();
$dirs = array();
$contents = array();
$it = new DirectoryIterator($path);
foreach ($it as $key => $file) {
$filename = $file->getFilename();
if ($it->isDot() && $this->_basePath == $path || $filename == '.' || $filename != '..' && $filename[0] == '.') {
continue;
}
$relPath = trim(str_replace($this->_basePath, '', realpath($file->getPathname())), '/\\');
$ext = strtolower(ltrim(strrchr($file->getFilename(), '.'), '.'));
if ($file->isDir()) {
$ext = null;
}
$type = 'generic';
switch (true) {
case in_array($ext, array('jpg', 'png', 'gif', 'jpeg', 'bmp', 'tif', 'svg')):
$type = 'image';
break;
case in_array($ext, array('txt', 'log', 'js')):
$type = 'text';
break;
case in_array($ext, array('html', 'htm')):
$type = 'markup';
break;
}
$dat = array('name' => $file->getFilename(), 'path' => $file->getPathname(), 'info' => $file->getPathInfo(), 'rel' => $relPath, 'ext' => $ext, 'type' => $type, 'is_dir' => $file->isDir(), 'is_file' => $file->isFile(), 'is_image' => $type == 'image', 'is_text' => $type == 'text', 'is_markup' => $type == 'markup');
if ($it->isDir()) {
$dirs[$relPath] = $dat;
} else {
if ($it->isFile()) {
$files[$relPath] = $dat;
}
}
$contents[$relPath] = $dat;
}
ksort($contents);
$this->view->paginator = $paginator = Zend_Paginator::factory($contents);
$paginator->setItemCountPerPage(20);
$paginator->setCurrentPageNumber($this->_getParam('page', 1));
$this->view->files = $files;
$this->view->dirs = $dirs;
$this->view->contents = $contents;
}
示例11: DirectoryIterator
function __construct()
{
$dir = new DirectoryIterator(dirname(__FILE__));
foreach ($dir as $file) {
if (!$dir->isFile()) {
continue;
}
list($code, $bs) = explode('.', $file);
if (strlen($code) != 2) {
continue;
}
include $file;
$this->names[$code] = $this->codes[$code];
}
}
示例12: doExecute
/**
* doExecute
*
* @return mixed
*/
public function doExecute()
{
try {
$lanDir = new \DirectoryIterator($this->config['dir.src'] . '/language');
} catch (\UnexpectedValueException $e) {
return;
}
// Each languages
foreach ($lanDir as $dir) {
if ($lanDir->isDot() || $lanDir->isFile()) {
continue;
}
$this->handleINIFile($dir->getBasename());
}
}
示例13: initLang
/**
* This should provide the feature that the lang package can be used from
* everywhere without to import it. Currently this is not working.
*/
private function initLang()
{
if ($this->initialized) {
return;
}
$dir = new \DirectoryIterator(__DIR__);
while ($dir->valid()) {
$file = $dir->getFilename();
if ($dir->isFile() && ($len = strpos($file, '.php')) === strlen($file) - 4) {
$name = substr($file, 0, $len);
$fullName = 'blaze\\lang\\' . $name;
$this->loadClass($fullName);
@class_alias($fullName, $name);
}
$dir->next();
}
}
示例14: getControllers
/**
* Scan the files in the configured path for controllers
*
* To dynamically scan controllers from the source files
* use PHP Reflection to find the controllers.
*
* The returning result is an array of Admin_Model_DbRow_Controller elements
*
* @return array
*/
public function getControllers()
{
$resources = array();
$directory = new DirectoryIterator($this->path);
$CcFilter = new Zend_Filter_Word_CamelCaseToDash();
while ($directory->valid()) {
if ($directory->isFile() && !in_array($directory->getFilename(), $this->skip, TRUE)) {
// load the file
require_once $directory->getPathname();
$reflect = new Zend_Reflection_File($directory->getPathName());
$name = substr($reflect->getClass()->getName(), strrpos($reflect->getClass()->getName(), "_") + 1);
$controller = new Admin_Model_DbRow_Controller(array('moduleName' => 'webdesktop', 'controllerName' => strtolower($name), 'virtual' => 1));
$resources[] = $controller;
}
$directory->next();
}
return $resources;
}
示例15: scanDir
/**
* scans the directory and returns all files
* @param string $directory
* @param string exclude
* @return array|null
*/
public function scanDir($directory, $exclude = '')
{
try {
$file = null;
$it = new DirectoryIterator($directory);
for ($it->rewind(); $it->valid(); $it->next()) {
if (!$it->isDir() && !$it->isDot() && $it->isFile()) {
if ($it->getFilename() == $exclude) {
continue;
}
$file[] = $it->getFilename();
}
}
return $file;
} catch (Exception $e) {
$logger = new debug_logger(MP_LOG_DIR);
$logger->log('error', 'php', 'An error has occured : ' . $e->getMessage(), debug_logger::LOG_VOID);
}
}