本文整理汇总了PHP中DirectoryIterator::getPathName方法的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryIterator::getPathName方法的具体用法?PHP DirectoryIterator::getPathName怎么用?PHP DirectoryIterator::getPathName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryIterator
的用法示例。
在下文中一共展示了DirectoryIterator::getPathName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: deleteEmptyDirectories
/**
* Delete empty directories (directories which contains only directories) starting from $dir
* @static
* @param string $dir
* @param Closure|string|null $log
* @return void
*/
static function deleteEmptyDirectories($dir, $log = null)
{
$iterator = new DirectoryIterator($dir);
$files_in_dir = 0;
foreach ($iterator as $node) {
if ($iterator->isDot()) {
continue;
}
$pathname = $iterator->getPathName();
$filename = $iterator->getFilename();
if ($iterator->isDir()) {
$files_in_dir += self::deleteEmptyDirectories($iterator->getPathName(), $log);
} else {
$files_in_dir++;
}
}
if ($files_in_dir == 0) {
if (null !== $log) {
$log("Remove empty dir '{$dir}'");
}
rmdir($dir);
}
return $files_in_dir;
}
示例5: 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;
}
示例6: WalkDirectory
/**
* the recursive function that walks through a directory of given path
*/
protected function WalkDirectory(DirectoryIterator $Directory, $pRecursiveWalk, $depth = 0)
{
$this->mStringFolderTree = str_repeat(' ', $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(' ', (1 + $depth) * 5) . $node->getFilename();
}
$Directory->next();
}
return $this->mStringFolderTree;
}
示例7: 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;
}
示例8: _getDirectories
protected function _getDirectories($iterator)
{
$iterator = new DirectoryIterator($iterator->getPathName());
$path = realpath(Zend_Registry::get('gallery_config')->imagepath);
$folders = array();
foreach ($iterator as $file) {
if (0 === strpos($file->getFileName(), '.')) {
continue;
}
if (!$file->isDir()) {
continue;
}
$dir = realpath($file->getPathName());
$dir = substr($dir, strlen($path) + 1);
$f = array('label' => $file->getFileName(), 'module' => 'default', 'controller' => 'index', 'action' => 'index', 'params' => array('path' => base64_encode($dir)));
$subdirs = $this->_getDirectories($file);
if ($subdirs) {
$f['pages'] = $subdirs;
}
$folders[] = $f;
}
return $folders;
}
示例9: removeOrphanRepositories
/**
* Remove orphan repositories.
*/
public static function removeOrphanRepositories()
{
$path = Pluf::f('idf_plugin_syncgit_base_repositories', '/home/git/repositories');
if (!is_dir($path) || is_link($path)) {
throw new Pluf_Exception_SettingError(sprintf('Directory %s does not exist! Setting "idf_plugin_syncgit_base_repositories not set.', $path));
}
if (!is_writable($path)) {
throw new Exception(sprintf('Repository %s is not writable.', $path));
}
$projects = array();
foreach (Pluf::factory('IDF_Project')->getList() as $project) {
$projects[] = $project->shortname;
}
unset($project);
$it = new DirectoryIterator($path);
$orphans = array();
while ($it->valid()) {
if (!$it->isDot() && $it->isDir() && !in_array(basename($it->getFileName(), '.git'), $projects)) {
$orphans[] = $it->getPathName();
}
$it->next();
}
if (count($orphans)) {
$cmd = Pluf::f('idf_exec_cmd_prefix', '') . 'rm -rf ' . implode(' ', $orphans);
exec($cmd);
clearstatcache();
while (list(, $project) = each($orphans)) {
if (is_dir($project)) {
throw new Exception(sprintf('Cannot remove %s directory.', $project));
}
}
}
}
示例10: processFile
/**
* This function is where all the lookup of the manual entry is.
*
* We are very lazy here: we suppress any errors that the Dom might throw at
* us, and we load the XML data as HTML - we're just interested in a particular
* node - no need to have a whole document that is valid, as long as we are able
* to get to the "methodsynopsis" node.
*
* @param object $file A DirectoryIterator instance
* @access private
* @return void
*/
private function processFile(DirectoryIterator $file)
{
$dom = new DomDocument();
@$dom->loadHTML(file_get_contents($file->getPathName()));
$xpath = new DomXpath($dom);
// Get the node where the description of the function call is:
$result = @$xpath->query("//methodsynopsis");
// Make sure we find a node:
if ($result->item(0)) {
$item = $result->item(0);
if ($this->settings->debug == 1) {
echo "\tparsing: " . $file->getFileName() . "\n";
}
/*
* Get the first para in the documentation, this might come
* out wrong for some of the functions, but: it's the closest
* we can come to something useful.
*/
$result = @$xpath->query("//para");
if ($result->item(0)) {
$para = simplexml_import_dom($result->item(0));
$desc = $para->asXml();
// defenently don't need tags for the terminal :)
$desc = htmlentities(strip_tags($desc));
// We don't need all the space/newlines around either
$desc = preg_replace("/[\r\n][\\s]+/", " ", $desc);
// Some of the functions are undocumented:
if (strstr($desc, "warn.undocumented.func;")) {
$desc = "Undocumented";
}
$item->appendChild($dom->createElement("desc", $desc));
}
$xml = simplexml_import_dom($item);
// Set the "function" attribute - this is what we will look for later.
$xml['function'] = (string) $xml->methodname;
$result = @$xpath->query("//para");
$this->buffer .= "\n" . $xml->asXml();
}
}
示例11: _getItemStats
/**
* Determine file/directory statistics for input item.
*
* @param DirectoryIterator $item Item passed from a DirectoryIterator
* @return array Listing with stats
*/
private static function _getItemStats(DirectoryIterator $item)
{
$list = array();
// add filename
$list['name'] = (string) $item;
// add directory/file type
$list['type'] = $item->getType();
// add modification time
$list['modified'] = date('Y-m-d H:i:s', $item->getMTime());
// get permissions
$list['permissions'] = $item->getPerms();
// is writable?
$list['writable'] = $item->isWritable() ? 1 : 0;
// add path
$list['path'] = $item->getPathName();
$list['real_path'] = $item->getRealPath();
// add size
$list['size'] = Fari_Format::bytes($item->getSize());
return $list;
}
示例12: cloneDirectoryIteratorAndCreateNewAutoRun
/**
* Cloning with the clone statement wasn't enough. I really need a new object.
* I create one with from the previous directory's path.
*/
private function cloneDirectoryIteratorAndCreateNewAutoRun(DirectoryIterator $dir)
{
$clone = new DirectoryIterator($dir->getPathName());
return new AutoRun(self::$lastTime, $clone);
}