本文整理汇总了PHP中DirectoryIterator::getPathname方法的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryIterator::getPathname方法的具体用法?PHP DirectoryIterator::getPathname怎么用?PHP DirectoryIterator::getPathname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryIterator
的用法示例。
在下文中一共展示了DirectoryIterator::getPathname方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanDir
/**
* Compacta todos os arquivos .php de um diretório removendo comentários,
* espaços e quebras de linhas desnecessárias.
* motivos de desempenho e segurança esse método so interage em um diretório
* de cada vez.
*
* @param string $directoryPath
* @param string $newFilesDirectory
* @param string $newFilesPrefix
* @param string $newFilesSufix
*/
public static function cleanDir($directoryPath, $newFilesDirectory = "packed", $newFilesPrefix = "", $newFilesSufix = "")
{
$dir = new DirectoryIterator($directoryPath);
mkdir($directoryPath . "/{$newFilesDirectory}/");
while ($dir->valid()) {
if (!$dir->isDir() and !$dir->isDot() and substr($dir->getFilename(), -3, 3) == 'php') {
$str = self::cleanFile($dir->getPathname());
$fp = fopen($dir->getPath() . "/packed/" . $newFilesPrefix . $dir->getFilename() . $newFilesSufix, "w");
fwrite($fp, $str);
fclose($fp);
echo $dir->getPathname() . ' - Renomeado com sucesso <br />';
}
$dir->next();
}
}
示例2: current
/**
* Returns the data of the current cache entry pointed to by the cache entry
* iterator.
*
* @return mixed
* @api
*/
public function current()
{
if ($this->cacheFilesIterator === NULL) {
$this->rewind();
}
return file_get_contents($this->cacheFilesIterator->getPathname());
}
示例3: ProcessFile
protected function ProcessFile(DirectoryIterator $pParent, DirectoryIterator $pNode)
{
$oldname = $pNode->getPathname();
$newname = $pParent->getPath() . '\\' . $this->GetLastFolderName($pParent->getPath()) . '.dds';
rename($oldname, $newname);
echo '<p>rename <b>' . $oldname . '</b> to <b>' . $newname . '<br/></p>';
}
示例4: current
/**
* Returns the data of the current cache entry pointed to by the cache entry
* iterator.
*
* @return mixed
* @api
*/
public function current()
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
$pathAndFilename = $this->cacheFilesIterator->getPathname();
return $this->readCacheFile($pathAndFilename);
}
示例5: compileFile
private function compileFile(\DirectoryIterator $file)
{
$tag = file_get_contents($file->getPathname());
$tagName = $file->getBasename('.html');
$jsFunc = $this->extractJsFunction($tag, $tagName);
$tagHtml = $this->removeJsFromTag($tag, $tagName);
$tagHtml = str_replace('"', '\\"', $tagHtml);
$tagHtml = preg_replace("/\r|\n/", "", $tagHtml);
return 'riot.tag("' . $tagName . '", "' . $tagHtml . '", ' . $jsFunc . ');';
}
示例6: current
/**
* Returns the data of the current cache entry pointed to by the cache entry
* iterator.
*
* @return mixed
* @api
*/
public function current()
{
if ($this->cacheFilesIterator === null) {
$this->rewind();
}
$pathAndFilename = $this->cacheFilesIterator->getPathname();
$lock = new Lock($pathAndFilename, false);
$result = file_get_contents($pathAndFilename);
$lock->release();
return $result;
}
示例7: addFromFile
/**
* @param DirectoryIterator $file
*/
private function addFromFile(DirectoryIterator $file)
{
$match = preg_match('/([^.]+)-custom.definition.json/', $file->getFilename(), $matches);
if (!$match) {
return;
}
$dictionaryName = $matches[1];
$translations = $this->loadTranslations($file->getPathname());
foreach ($translations as $translationName => $translations) {
$this->includeTranslation($dictionaryName, $translationName, $translations);
}
}
示例8: load_plugin
private static function load_plugin(ContextManager $context, DirectoryIterator $plugin_path)
{
$plugin_load_file = $plugin_path->getPathname() . DIRECTORY_SEPARATOR . 'init.php';
if ($plugin_path->isDir() && is_file($plugin_load_file) && (require $plugin_load_file)) {
$class = Plugins::plugin_class_name($plugin_path);
try {
$klass = new ReflectionClass($class);
Plugins::add($klass->newInstance($context));
$context->logger()->debugf('%s --> %s', str_replace(MEDICK_PATH, '${' . $context->config()->application_name() . '}', $plugin_load_file), $class);
} catch (ReflectionException $rfEx) {
$context->logger()->warn('failed to load plugin `' . $plugin_path->getFilename() . '`: ' . $rfEx->getMessage());
}
}
}
示例9: 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;
}
示例10: getFilesInDir
/**
* Iterates over a directory and returns file objects.
*
* @param string $dir
* @param mixed $filter
* @param bool $recursive defaults to false
* @param bool $addDirs return directories as well as files - defaults to false
* @return array
*
*/
function getFilesInDir($dir, $filter = '', $recursive = false, $addDirs = false)
{
$res = array();
$dirIterator = new DirectoryIterator($dir);
while ($dirIterator->valid()) {
if (!$dirIterator->isDot()) {
$file = $dirIterator->getPathname();
$isDir = is_dir($file);
if (!$isDir || $addDirs) {
if (empty($filter) || fnmatch($filter, $file)) {
$res[] = $file;
}
}
if ($isDir && $recursive) {
$res = array_merge($res, getFilesInDir($file, $filter = '', $recursive));
}
}
$dirIterator->next();
}
return $res;
}
示例11: recursivelyDeleteDirectory
/**
* Iteratively remove/delete a directory and its contents
*
* @param DirectoryIterator $path base directory (inclusive) to recursively delete.
*/
function recursivelyDeleteDirectory(DirectoryIterator $path)
{
// echo $path . " being deleted?";
if ($path->isDir()) {
$directory = new DirectoryIterator($path->getPath() . DIRECTORY_SEPARATOR . $path->getFilename());
// For each element within this directory, delete it or recurse into next directory
foreach ($directory as $object) {
if (!$object->isDot()) {
if ($object->isDir()) {
recursivelyDeleteDirectory($object);
} else {
unlink($object->getPathname());
}
}
}
rmdir($path->getPathname());
} else {
// Not a directory...
// Do nothing
}
}
示例12: getDirInfo
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">';
getDirInfo($iterator->getPathname());
echo '</ul></li>';
}
$iterator->next();
}
#再输出文件
$iterator->Rewind();
while ($iterator->valid()) {
if ($iterator->isFile()) {
echo '<li class="flist file"><i class="fa fa-file-text"></i> ' . $iterator->getFilename() . '</li>';
}
$iterator->next();
}
}
示例13: deleteDirectoryRecursive
/**
* Removes the given directory recursive.
*
* @param DirectoryIterator $it The context directory iterator.
*
* @return void
*/
private static function deleteDirectoryRecursive(DirectoryIterator $it)
{
foreach ($it as $file) {
if ($it->isDot()) {
continue;
} else {
if ($it->isDir()) {
self::deleteDirectoryRecursive($it->getChildren());
rmdir($it->getPathname());
} else {
unlink($it->getPathname());
}
}
}
}
示例14: isset
</div>
</div>
</form>
</div>
<pre>
<?php
if ($_POST) {
$path = $_POST['path'];
$ext = isset($_POST['ext']) ? $_POST['ext'] : 'zip';
echo $path . PHP_EOL;
$dir = new DirectoryIterator($path);
$batch = '';
while ($dir->valid()) {
if ($dir->isDir() && !$dir->isDot()) {
$source_dir = $dir->getPathname();
$dest_file = $source_dir . '.' . $ext;
$command = "7z a \"{$dest_file}\" \"{$source_dir}\\*\" -tzip -mx0" . PHP_EOL;
echo $command;
$batch .= $command;
}
$dir->next();
}
$final = $path . '\\' . 'zip.bat';
echo $final . PHP_EOL;
var_dump(file_put_contents($final, $batch));
}
?>
</pre>
<?php
include '_footer.php';
示例15: array
<div class="container-fluid full-height">
<div class="row full-height">
<div class="col-md-12 full-height main-frame-container">
<div class="panel panel-primary main-frame">
<div class="panel-heading">Package Manager</div>
<div class="panel-body">
<div class="file-detail full-height col-md-4"></div>
<div class="file-manager scroll-pane full-height col-md-12">
<?php
$files_array = array();
$dir = new DirectoryIterator(dirname(__FILE__) . "/packages");
while ($dir->valid()) {
if (!$dir->isDot() && $dir->isDir()) {
// sort key, ie. modified timestamp
$key = $dir->getCTime();
$data = array($dir->getFilename(), dirsize($dir->getPathname()));
$files_array[$key] = $data;
}
$dir->next();
}
ksort($files_array);
$files_array = array_reverse($files_array, true);
foreach ($files_array as $key => $fileinfo) {
?>
<div class="dir-item" data-package="<?php
echo $fileinfo[0];
?>
"><a href="?package=<?php
echo $fileinfo[0];
?>
" onClick="return false;">