本文整理汇总了PHP中DirectoryIterator::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP DirectoryIterator::getPath方法的具体用法?PHP DirectoryIterator::getPath怎么用?PHP DirectoryIterator::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DirectoryIterator
的用法示例。
在下文中一共展示了DirectoryIterator::getPath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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>';
}
示例2: searchInDir
/**
* Método recursivo que busca o arquivo em todas as pastadas dentro do
* diretorio específicado
*
* @param string $dir
* @param string $file
* @return boolean
*/
public static function searchInDir($dir, $file)
{
if (is_file($dir . "/" . $file)) {
require_once $dir . "/" . $file;
self::$find = true;
if (self::$sugests) {
$fileName = $dir . "/" . $file;
$fileName = str_replace(self::$currentPath, "", $fileName);
echo "require_once '" . $fileName . "';<br>\n";
}
return true;
}
if (is_dir($dir)) {
$d = new DirectoryIterator($dir);
while (!self::$find && $d->valid()) {
if (is_dir($d->getPath() . '/' . $d->getFilename())) {
//testa se o arquivo pode ser incluido
$inc = true;
foreach (self::$blockedDirs as $bDir) {
if ($d->getFilename() == $bDir) {
$inc = false;
break;
}
}
if (!$d->isDot() && $inc) {
self::searchInDir($d->getPath() . '/' . $d->getFilename(), $file);
}
}
$d->next();
}
}
return self::$find;
}
示例3: readDir
public function readDir($dirPath)
{
$di = new DirectoryIterator($dirPath);
$array = array();
while ($di->valid()) {
if (!$di->isDot() && $this->validateDir($di->getFilename())) {
if ($di->isDir()) {
$dir = $di->getPath() . '/' . $di->getFilename();
$array[$di->getFilename()] = $this->readDir($di->getPath() . '/' . $di->getFilename());
} else {
$array[$di->getFilename()] = $di->getPath() . "/" . $di->getFilename();
}
}
$di->next();
}
return $array;
}
示例4: 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();
}
示例5: compileAll
private function compileAll(\DirectoryIterator $iterator)
{
$jsContent = "";
/** @var $info \DirectoryIterator */
foreach ($iterator as $info) {
if ($info->isFile()) {
$jsContent .= $this->compileFile($info);
} elseif (!$info->isDot()) {
$jsContent .= $this->compileAll(new \DirectoryIterator($iterator->getPath() . DIRECTORY_SEPARATOR . $info->getBasename()));
}
}
return $jsContent;
}
示例6: getPlugins
public function getPlugins()
{
$output = array();
$it = new DirectoryIterator(BASE . 'plugins/');
while ($it->valid()) {
$xml_path = $it->getPath() . $it->getFilename() . '/';
$xml_file = $xml_path . "plugin.xml";
if ($it->isReadable() && $it->isDir() && file_exists($xml_file)) {
$output[] = new PapyrinePlugin($xml_path);
}
$it->next();
}
return $output;
}
示例7: 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();
}
}
示例8: 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
}
}
示例9: die
<?php
// no direct access
defined('PARENT_FILE') or die('Restricted access');
if ($this->authorize()) {
$confirm = file_get_contents(__SITE_PATH . '/templates/' . $this->registry->template . '/html/confirm.html');
$js = new JsLoader($this->registry);
$js->source_root = $this->registry->config->get('web_url', 'SERVER') . '/Common/javascript/Source/';
$dirs = array($_SERVER['DOCUMENT_ROOT'] . '/templates/', $_SERVER['DOCUMENT_ROOT'] . '/../templates/');
foreach ($dirs as $dir) {
$iterator = new DirectoryIterator($dir);
$path = $iterator->getPath();
foreach ($iterator as $fileinfo) {
if (!$fileinfo->isDot()) {
if ($fileinfo->isDir()) {
$templates[$fileinfo->getFilename()] = $path . '/' . $fileinfo->getFilename();
}
}
}
unset($iterator);
}
ksort($templates);
if (isset($_POST['template'])) {
$template = $templates[$_POST['template']];
$template_name = $_POST['template'];
} else {
$template = $templates[$this->registry->admin_config->get('admin_template', 'SERVER')];
$template_name = $this->registry->admin_config->get('admin_template', 'SERVER');
}
$template_files = new Admin_Config($this->registry, array('path' => $template . '/ini/template.ini.php'));
$template_files->public_html = true;
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
// Fetch all the aliases
$aliases = $this->mimetypeDetector->getAllAliases();
// Remove comments
$keys = array_filter(array_keys($aliases), function ($k) {
return $k[0] === '_';
});
foreach ($keys as $key) {
unset($aliases[$key]);
}
// Fetch all files
$dir = new \DirectoryIterator(\OC::$SERVERROOT . '/core/img/filetypes');
$files = [];
foreach ($dir as $fileInfo) {
if ($fileInfo->isFile()) {
$file = preg_replace('/.[^.]*$/', '', $fileInfo->getFilename());
$files[] = $file;
}
}
//Remove duplicates
$files = array_values(array_unique($files));
// Fetch all themes!
$themes = [];
$dirs = new \DirectoryIterator(\OC::$SERVERROOT . '/themes/');
foreach ($dirs as $dir) {
//Valid theme dir
if ($dir->isFile() || $dir->isDot()) {
continue;
}
$theme = $dir->getFilename();
$themeDir = $dir->getPath() . '/' . $theme . '/core/img/filetypes/';
// Check if this theme has its own filetype icons
if (!file_exists($themeDir)) {
continue;
}
$themes[$theme] = [];
// Fetch all the theme icons!
$themeIt = new \DirectoryIterator($themeDir);
foreach ($themeIt as $fileInfo) {
if ($fileInfo->isFile()) {
$file = preg_replace('/.[^.]*$/', '', $fileInfo->getFilename());
$themes[$theme][] = $file;
}
}
//Remove Duplicates
$themes[$theme] = array_values(array_unique($themes[$theme]));
}
//Generate the JS
$js = '/**
* This file is automatically generated
* DO NOT EDIT MANUALLY!
*
* You can update the list of MimeType Aliases in config/mimetypealiases.json
* The list of files is fetched from core/img/filetypes
* To regenerate this file run ./occ maintenance:mimetypesjs
*/
OC.MimeTypeList={
aliases: ' . json_encode($aliases, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . ',
files: ' . json_encode($files, JSON_PRETTY_PRINT) . ',
themes: ' . json_encode($themes, JSON_PRETTY_PRINT) . '
};
';
//Output the JS
file_put_contents(\OC::$SERVERROOT . '/core/js/mimetypelist.js', $js);
$output->writeln('<info>mimetypelist.js is updated');
}
示例11: _deleteDir
protected static function _deleteDir($dirPath)
{
$iterator = new DirectoryIterator($dirPath);
foreach ($iterator as $fileInfo) {
if ($fileInfo->isDot()) {
continue;
}
if ($fileInfo->isDir()) {
self::_deleteDir($fileInfo->getPathname());
} else {
unlink($fileInfo->getPathname());
}
}
rmdir($iterator->getPath());
}
示例12: generate
/**
* Generate app skeleton on current directory
*
* @param string Namespace
* @return stream
*/
public static function generate($namespace = 'App')
{
$namespace = ucfirst(strtolower($namespace));
$isApp = (bool) ($namespace === 'App');
$currentDirectory = new \DirectoryIterator($_SERVER['PWD']);
// Initialize by validate current directory
if ($currentDirectory->isDir() && $currentDirectory->isWritable()) {
// Create directory structure
self::out(I18n::translate('command_generate_folders'));
$appFolder = $currentDirectory->getPath() . DIRECTORY_SEPARATOR . $namespace;
$controllerFolder = $currentDirectory->getPath() . DIRECTORY_SEPARATOR . $namespace . DIRECTORY_SEPARATOR . 'Controller';
$testsFolder = $currentDirectory->getPath() . DIRECTORY_SEPARATOR . $namespace . DIRECTORY_SEPARATOR . 'Tests';
$directories = compact('appFolder', 'controllerFolder', 'testsFolder');
foreach ($directories as $name => $directory) {
$directory = $isApp ? str_replace($namespace, strtolower($namespace), $directory) : $directory;
is_dir($directory) or mkdir($directory, 0755, TRUE);
// Reset paths
${$name} = $directory;
}
// Create controller and model
self::out(I18n::translate('command_generate_files'));
$controllerTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'Controller.php.tpl');
$phpunitTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'phpunit.xml.tpl');
$bootstrapTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'bootstrap.php.tpl');
$testTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'ControllerTest.php.tpl');
$routePath = $isApp ? '' : strtolower($namespace) . '.';
File::write($controllerFolder . DIRECTORY_SEPARATOR . 'HelloController.php', sprintf($controllerTemplate, $namespace, $namespace, $namespace));
File::write($testsFolder . DIRECTORY_SEPARATOR . 'phpunit.xml', sprintf($phpunitTemplate, $namespace));
File::write($testsFolder . DIRECTORY_SEPARATOR . 'bootstrap.php', sprintf($bootstrapTemplate, PATH_SYS . DIRECTORY_SEPARATOR . 'Juriya.php'));
File::write($testsFolder . DIRECTORY_SEPARATOR . 'HelloControllerTest.php', sprintf($testTemplate, $namespace, $namespace, $routePath, $routePath, $routePath));
// Generate basic YAML configuration files
self::out(I18n::translate('command_generate_configuration'));
$routesTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'routes.yml.tpl');
$packagesTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'packages.yml.tpl');
$modulesTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'modules.yml.tpl');
File::write($appFolder . DIRECTORY_SEPARATOR . 'routes.yml', sprintf($routesTemplate, $namespace));
File::write($appFolder . DIRECTORY_SEPARATOR . 'packages.yml', $packagesTemplate);
File::write($appFolder . DIRECTORY_SEPARATOR . 'modules.yml', $modulesTemplate);
if ($isApp) {
// Generate front socket if the requsted app is Application
self::out(I18n::translate('command_generate_front_socket'));
$publicDirectory = $currentDirectory->getPath() . DIRECTORY_SEPARATOR . 'public';
is_dir($publicDirectory) or mkdir($publicDirectory, 0755, TRUE);
$indexTemplate = File::read(PATH_SYS . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'index.php.tpl');
File::write($publicDirectory . DIRECTORY_SEPARATOR . 'index.php', sprintf($indexTemplate, PATH_SYS . DIRECTORY_SEPARATOR . 'Juriya.php'));
}
self::out(Utility::getColoredString(I18n::translate('command_generate_done'), 'black', 'green'));
} else {
self::out(I18n::translate('file_not_writable', $currentDirectory->getPath()));
self::out(Utility::getColoredString(I18n::translate('command_generate_fail'), 'black', 'red'));
}
}
示例13: deleteDir
public static function deleteDir($dirPath)
{
$iterator = new DirectoryIterator($dirPath);
foreach ($iterator as $fileInfo) {
if ($fileInfo->isDot()) {
continue;
}
if ($fileInfo->isDir()) {
self::deleteDir($fileInfo->getPathname());
} else {
$fileName = $fileInfo->getFilename();
if ($fileName[0] == '.') {
continue;
}
unlink($fileInfo->getPathname());
}
}
rmdir($iterator->getPath());
}
示例14: patchXml
/**
* @param DirectoryIterator $fileInfo
*/
private function patchXml(\DirectoryIterator $fileInfo)
{
if ($fileInfo->isFile()) {
$filePath = $fileInfo->getPathname();
if (!preg_match('/\\.orm\\.xml$/', $fileInfo->getFilename())) {
return;
} else {
preg_match('/(.*)\\.orm\\.xml/', $fileInfo->getFilename(), $m);
$className = $m[1];
}
//replase
$contentMap = ['column="order"' => 'column="`order`"', 'column="from"' => 'column="`from`"', 'column="to"' => 'column="`to`"', 'column="user"' => 'column="`user`"'];
$content = file_get_contents($filePath);
$content = str_replace(array_keys($contentMap), array_values($contentMap), $content);
//rename
$filenameMap = [];
if (isset($filenameMap[$fileInfo->getFilename()])) {
unlink($filePath);
$filePath = $fileInfo->getPath() . '/' . $filenameMap[$fileInfo->getFilename()];
}
$content = $this->addGedmoLoggable($content, $className);
file_put_contents($filePath, $content);
}
}
示例15: _copyFile
/**
* Copy file
*
* @param int $fileID
* @param DirectoryIterator $entries
* @return void|string
*/
protected final function _copyFile($fileID, DirectoryIterator $entries)
{
// Generate storage filename
$storeAs = str_replace(array('%scanID%', '%fileID%', '%fullPath%', '%relativePath%', '%filename%', '%to%'), array($this->_scanRow->scanID, $fileID, $entries->getPath() . '/', ltrim(mb_substr($entries->getPath() . '/', mb_strlen($this->_currentRoot)), '/'), $entries->getFilename(), $this->_currentTo), $this->_naming);
// Destination
$destination = $this->_storagePath . $storeAs;
// Check destination directory
$path = dirname($destination);
if (!realpath($path)) {
// Create
if (!mkdir($path, $this->_storageDirectoryMode, true)) {
$this->_log(self::LOG_ERROR, "\tCan't create {$path}");
return;
}
}
// Copy
copy($entries->getPathname(), $destination);
// Date
if ($this->_copyWithDate) {
touch($destination, $entries->getMTime());
}
return '/' . $storeAs;
}