本文整理汇总了PHP中RecursiveIteratorIterator::isFile方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::isFile方法的具体用法?PHP RecursiveIteratorIterator::isFile怎么用?PHP RecursiveIteratorIterator::isFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecursiveIteratorIterator
的用法示例。
在下文中一共展示了RecursiveIteratorIterator::isFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rmdir
/**
* Remove recursively the directory named by dirname.
*
* @param string $dirname Path to the directory
* @param boolean $followLinks Removes symbolic links if set to true
* @return boolean True if success otherwise false
* @throws Exception When the directory does not exist or permission denied
*/
public static function rmdir($dirname, $followLinks = false)
{
if (!is_dir($dirname) && !is_link($dirname)) {
throw new Exception(sprintf('Directory %s does not exist', $dirname));
}
if (!is_writable($dirname)) {
throw new Exception('You do not have renaming permissions');
}
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST);
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if (!$iterator->isWritable()) {
throw new Exception(sprintf('Permission denied for %s', $iterator->getPathName()));
}
if ($iterator->isLink() && false === (bool) $followLinks) {
$iterator->next();
continue;
}
if ($iterator->isFile()) {
unlink($iterator->getPathName());
} else {
if ($iterator->isDir()) {
rmdir($iterator->getPathName());
}
}
}
$iterator->next();
}
unset($iterator);
return rmdir($dirname);
}
示例2: recursive_rmdir
private function recursive_rmdir($dirname, $followLinks = false)
{
if (is_dir($dirname) && !is_link($dirname)) {
if (!is_writable($dirname)) {
throw new Exception('You do not have renaming permissions!');
}
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname), RecursiveIteratorIterator::CHILD_FIRST);
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if (!$iterator->isWritable()) {
throw new Exception(sprintf('Permission Denied: %s.', $iterator->getPathName()));
}
if ($iterator->isLink() && false === (bool) $followLinks) {
$iterator->next();
}
if ($iterator->isFile()) {
unlink($iterator->getPathName());
} else {
if ($iterator->isDir()) {
rmdir($iterator->getPathName());
}
}
}
$iterator->next();
}
unset($iterator);
// Fix for Windows.
return rmdir($dirname);
} else {
throw new Exception(sprintf('Directory %s does not exist!', $dirname));
}
}
示例3: execute
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute()
{
global $CFG;
$tmpdir = $CFG->tempdir;
// Default to last weeks time.
$time = strtotime('-1 week');
$dir = new \RecursiveDirectoryIterator($tmpdir);
// Show all child nodes prior to their parent.
$iter = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::CHILD_FIRST);
for ($iter->rewind(); $iter->valid(); $iter->next()) {
$node = $iter->getRealPath();
if (!is_readable($node)) {
continue;
}
// Check if file or directory is older than the given time.
if ($iter->getMTime() < $time) {
if ($iter->isDir() && !$iter->isDot()) {
// Don't attempt to delete the directory if it isn't empty.
if (!glob($node . DIRECTORY_SEPARATOR . '*')) {
if (@rmdir($node) === false) {
mtrace("Failed removing directory '{$node}'.");
}
}
}
if ($iter->isFile()) {
if (@unlink($node) === false) {
mtrace("Failed removing file '{$node}'.");
}
}
}
}
}
示例4: execute
/**
* Do the job.
* Throw exceptions on errors (the job will be retried).
*/
public function execute()
{
global $CFG;
$tmpdir = $CFG->tempdir;
// Default to last weeks time.
$time = time() - $CFG->tempdatafoldercleanup * 3600;
$dir = new \RecursiveDirectoryIterator($tmpdir);
// Show all child nodes prior to their parent.
$iter = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::CHILD_FIRST);
// An array of the full path (key) and date last modified.
$modifieddateobject = array();
// Get the time modified for each directory node. Nodes will be updated
// once a file is deleted, so we need a list of the original values.
for ($iter->rewind(); $iter->valid(); $iter->next()) {
$node = $iter->getRealPath();
if (!is_readable($node)) {
continue;
}
$modifieddateobject[$node] = $iter->getMTime();
}
// Now loop through again and remove old files and directories.
for ($iter->rewind(); $iter->valid(); $iter->next()) {
$node = $iter->getRealPath();
if (!is_readable($node)) {
continue;
}
// Check if file or directory is older than the given time.
if ($modifieddateobject[$node] < $time) {
if ($iter->isDir() && !$iter->isDot()) {
// Don't attempt to delete the directory if it isn't empty.
if (!glob($node . DIRECTORY_SEPARATOR . '*')) {
if (@rmdir($node) === false) {
mtrace("Failed removing directory '{$node}'.");
}
}
}
if ($iter->isFile()) {
if (@unlink($node) === false) {
mtrace("Failed removing file '{$node}'.");
}
}
} else {
// Return the time modified to the original date only for real files.
if ($iter->isDir() && !$iter->isDot()) {
touch($node, $modifieddateobject[$node]);
}
}
}
}
示例5: _recursive_rmdir
/**
* Attempts to remove recursively the directory named by dirname.
*
* @author Mehdi Kabab <http://pioupioum.fr>
* @copyright Copyright (C) 2009 Mehdi Kabab
* @license http://www.gnu.org/licenses/gpl.html GNU GPL version 3 or later
*
* @param string $dirname Path to the directory.
* @return null
*/
private function _recursive_rmdir($dirname)
{
if (is_dir($dirname) && !is_link($dirname)) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dirname), \RecursiveIteratorIterator::CHILD_FIRST);
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if ($iterator->isFile()) {
unlink($iterator->getPathName());
} else {
if ($iterator->isDir()) {
rmdir($iterator->getPathName());
}
}
}
$iterator->next();
}
unset($iterator);
// Fix for Windows.
rmdir($dirname);
}
}
示例6: execute
/**
* Executes the transformation process.
*
* @throws Zend_Console_Getopt_Exception
*
* @return void
*/
public function execute()
{
$results = array();
$longest_name = 0;
/** @var RecursiveDirectoryIterator $files */
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(dirname(__FILE__) . '/../'));
while ($files->valid()) {
// skip abstract files
if (!$files->isFile() || $files->getBasename() == 'Abstract.php') {
$files->next();
continue;
}
// convert the filename to a class
$class_name = 'DocBlox_Task_' . str_replace(DIRECTORY_SEPARATOR, '_', $files->getSubPath()) . '_' . $files->getBasename('.php');
// check if the class exists, if so: add it to the list
if (class_exists($class_name)) {
$name = $files->getBasename('.php');
$longest_name = max(strlen($name), $longest_name);
$results[strtolower($files->getSubPath())][strtolower($name)] = $files->getRealPath();
}
$files->next();
}
// echo the list of namespaces with their tasks
ksort($results, SORT_STRING);
foreach ($results as $namespace => $tasks) {
echo $namespace . PHP_EOL;
asort($tasks, SORT_STRING);
foreach ($tasks as $task => $filename) {
// get the short description by reflecting the file.
$refl = new DocBlox_Reflection_File($filename, false);
$refl->setLogLevel(DocBlox_Core_Log::QUIET);
$refl->process();
/** @var DocBlox_Reflection_Class $class */
$class = current($refl->getClasses());
echo ' :' . str_pad($task, $longest_name + 2) . $class->getDocBlock()->getShortDescription() . PHP_EOL;
}
}
echo PHP_EOL;
}
示例7: UnlinkDPL
function UnlinkDPL()
{
global $TopDirectory;
try {
$TopDirectoryCnt = count($TopDirectory);
//print "TopDirectoryCnt: " . $TopDirectoryCnt . $NL;
foreach ($TopDirectory as $Dir => $RM) {
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Dir));
while ($it->valid()) {
if ($it->isFile()) {
$ext = pathinfo($it->current(), PATHINFO_EXTENSION);
if ($ext == "dpl") {
unlink($it->getPathName());
}
}
$it->next();
}
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例8: array
function get_image_file_array($folder)
{
$count = 0;
$images = array();
$image_data = array();
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folder));
$ext = array('.png', '.jpeg', '.jpg', '.jpe', '.gif', '.png', '.bmp', 'tif', 'tiff', '.ico');
$skip_paths = explode("\r\n", get_option('image_cleanup_skip_paths', null));
$skip_paths[] = 'imagecleanup';
$start = microtime(true);
$debuglog = self::$UPLOAD_DIR . '/imagecleanup/debug.json';
while ($it->valid()) {
if (!$it->isDot()) {
if ($it->isFile()) {
if ($this->strposa($it->getFilename(), $ext) !== false) {
//$image_data['att_id'] = 'uknown';
$image_data['bd'] = dirname($it->key());
$image_data['fn'] = $it->getFilename();
$image_data['xist'] = true;
//stupid, yes-- but it saves a file_exist later on?
$skip = false;
$file = $image_data['bd'] . '/' . $image_data['fn'];
// check if path in skip array
foreach ($skip_paths as $key) {
// check if str in complete path and filename
if (stripos($file, $key) !== false) {
$skip = true;
}
}
if (!$skip) {
$images[] = $image_data;
}
$count++;
}
}
}
$it->next();
}
return $images;
}
示例9: removeDirectory
public function removeDirectory($directory, $recursive = false)
{
$directory = $this->path($directory);
// Recursive
if ($recursive) {
$return = true;
// Iterate over contents
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::KEY_AS_PATHNAME), RecursiveIteratorIterator::CHILD_FIRST);
foreach ($it as $key => $child) {
if ($child->getFilename() == '..' || $child->getFilename() == '.') {
continue;
}
if ($child->isDir()) {
$return &= $this->removeDirectory($child->getPathname(), false);
} else {
if ($it->isFile()) {
$return &= $this->unlink($child->getPathname(), false);
}
}
}
$return &= $this->removeDirectory($directory, false);
} else {
$return = @rmdir($directory);
}
if (false === $return) {
throw new Engine_Vfs_Adapter_Exception(sprintf('Unable to remove directory "%s"', $directory));
}
return $return;
}
示例10: exit
* @copyright Copyright (c) 2010-2011 lab2023 -
* internet technologies TURKEY Inc. (http://www.lab2023.com)
* @license http://www.kebab-project.com/cms/licensing
* @version 1.5.0
*/
/**
* Kebab Project Asset Loader
*
* On-Demad load and return all js files
* @uses SPL - Standard PHP Library :: RecursiveIteratorIterator, RecursiveDirectoryIterator
*/
if (phpversion() < 5) {
exit('/* Kebab Project Asset Loader requires PHP5 or greater. */');
}
ob_start("ob_gzhandler");
header("Content-type: text/javascript; charset: UTF-8");
// Define root path
defined('BASE_PATH') || define('BASE_PATH', realpath(dirname(__FILE__)) . '/');
// Recursive scan directory and files
$scanner = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(BASE_PATH));
while ($scanner->valid()) {
if (!$scanner->isDot() && $scanner->isFile()) {
$pathInfo = pathinfo($scanner->key());
if (@$pathInfo['extension'] == 'js') {
@readfile($scanner->key());
print PHP_EOL;
}
}
$scanner->next();
}
ob_end_flush();
示例11: fsRmdirRecursive
public static function fsRmdirRecursive($path, $includeSelf = false)
{
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME), RecursiveIteratorIterator::CHILD_FIRST);
foreach ($it as $key => $child) {
if ($child->getFilename() == '.' || $child->getFilename() == '..') {
continue;
}
if ($it->isDir()) {
if (!rmdir($key)) {
throw new Engine_Package_Exception(sprintf('Unable to remove directory: %s', $key));
}
} else {
if ($it->isFile()) {
if (!unlink($key)) {
throw new Engine_Package_Exception(sprintf('Unable to remove file: %s', $key));
}
}
}
}
if (is_dir($path) && $includeSelf) {
if (!rmdir($path)) {
throw new Engine_Package_Exception(sprintf('Unable to remove directory: %s', $path));
}
}
}
示例12: RecursiveRmdir
/**
* Recursively remove a directory
*
* @param string $dirname
* @param boolean $followSymlinks
* @return boolean
*/
function RecursiveRmdir($dirname, $followSymlinks = false)
{
if (is_dir($dirname) && !is_link($dirname)) {
if (!is_writable($dirname)) {
throw new \Exception(sprintf('%s is not writable!', $dirname));
}
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dirname), \RecursiveIteratorIterator::CHILD_FIRST);
while ($iterator->valid()) {
if (!$iterator->isDot()) {
if (!$iterator->isWritable()) {
throw new \Exception(sprintf('%s is not writable!', $iterator->getPathName()));
}
if ($iterator->isLink() && $followLinks === false) {
$iterator->next();
}
if ($iterator->isFile()) {
@unlink($iterator->getPathName());
} elseif ($iterator->isDir()) {
@rmdir($iterator->getPathName());
}
}
$iterator->next();
}
unset($iterator);
return @rmdir($dirname);
} else {
throw new \Exception(sprintf('%s does not exist!', $dirname));
}
}
示例13: getPhotonFiles
/**
* Returns the list of files for Photon.
*
* This is an array with the key being the path to use in the phar
* and the value the path on disk. photon.php and
* photon/autoload.php are not included.
*
* @return array files
*/
public function getPhotonFiles()
{
$out = array();
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->photon_path), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($files as $disk_path => $file) {
if (!$files->isFile()) {
continue;
}
$phar_path = substr($disk_path, strlen($this->photon_path) + 1);
if (false !== strpos($phar_path, 'photon/tests/')) {
$this->verbose("[PHOTON IGNORE] " . $phar_path);
continue;
}
if (false !== strpos($phar_path, 'photon/data/project_template')) {
$this->verbose("[PHOTON IGNORE] " . $phar_path);
continue;
}
if ($phar_path == 'photon/autoload.php') {
$this->verbose("[PHOTON IGNORE] " . $phar_path);
continue;
}
if ($phar_path == 'photon.php') {
$this->verbose("[PHOTON IGNORE] " . $phar_path);
continue;
}
$out[$phar_path] = $disk_path;
$this->verbose("[PHOTON ADD] " . $phar_path);
}
return $out;
}
示例14: Phar
$scriptFilename = "scripts/{$binary}.php";
$pharFilename = "bin/{$binary}.phar";
$binaryFilename = "bin/{$binary}";
if (file_exists($pharFilename)) {
Phar::unlinkArchive($pharFilename);
}
if (file_exists($binaryFilename)) {
Phar::unlinkArchive($binaryFilename);
}
$phar = new Phar($pharFilename, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO, $binary);
$phar->startBuffering();
$directories = array('src', 'vendor', 'scripts');
foreach ($directories as $dirname) {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname));
while ($iterator->valid()) {
if ($iterator->isFile()) {
$path = $iterator->getPathName();
if ('php' == strtolower($iterator->getExtension())) {
$contents = php_strip_whitespace($path);
$phar->addFromString($path, $contents);
} else {
$phar->addFile($path);
}
}
$iterator->next();
}
}
$stub = "#!/usr/bin/env php\n" . $phar->createDefaultStub($scriptFilename);
$phar->setStub($stub);
$phar->compressFiles(Phar::GZ);
$phar->stopBuffering();
示例15: Main
function Main($DoLevel)
{
global $NL;
global $RootMenu;
global $SubMenuType;
global $TopDirectory;
global $AppDir;
global $DATABASE_FILENAME;
$AppDir = "site/";
if (!file_exists($AppDir . "folder")) {
mkdir($AppDir . "folder");
}
if (!file_exists($AppDir . "sprites")) {
mkdir($AppDir . "sprites");
}
$NumNewPlaylists = 0;
//Create a didl file in each directory containing music
if ($DoLevel > 3) {
echo "Removing old .dpl files" . $NL;
UnlinkDPL();
}
echo "Making a didl file in each directory..." . $NL;
$NumNewPlaylists = MakePlaylists($TopDirectory);
echo " - found {$NumNewPlaylists} new playlists" . $NL;
unlink($DATABASE_FILENAME);
$musicDB = new MusicDB();
echo "Find all didl files and add to Menu tree..." . $NL;
// Find all didl files and add it to the menus
try {
CreateAllGreyImgs($musicDB->MaxPreset());
foreach ($TopDirectory as $Dir => $RootMenuNo) {
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Dir));
while ($it->valid()) {
if ($it->isFile()) {
$ext = pathinfo($it->current(), PATHINFO_EXTENSION);
if ($ext == "xml") {
$didl = new DIDL_Album($it->getPathName(), $RootMenuNo);
$rowid = $musicDB->CheckURLExist($didl->URI());
if ($rowid === false) {
$rowid = Make_Album($didl, $musicDB);
Make_Tracks($didl, $musicDB);
//$didl->dump();
} else {
$didl->SetSequenceNo($rowid);
}
CollectFolderImgs($didl);
echo ".";
}
}
$it->next();
}
}
} catch (Exception $e) {
echo $e->getMessage();
}
copy("index.php", $AppDir . "index.php");
copy("html_parts.php", $AppDir . "html_parts.php");
copy("actions.js", $AppDir . "actions.js");
copy("musik.css", $AppDir . "musik.css");
copy("LinnDS-jukebox-daemon.php", $AppDir . "LinnDS-jukebox-daemon.php");
copy("ServerState.php", $AppDir . "ServerState.php");
copy("LPECClientSocket.php", $AppDir . "LPECClientSocket.php");
copy("LinnDSClientSocket.php", $AppDir . "LinnDSClientSocket.php");
copy("StringUtils.php", $AppDir . "StringUtils.php");
copy("SocketServer.php", $AppDir . "SocketServer.php");
copy("LinnDS-jukebox-daemon-old.php", $AppDir . "LinnDS-jukebox-daemon-old.php");
copy("S98linn_lpec", $AppDir . "S98linn_lpec");
copy("Transparent.gif", $AppDir . "Transparent.gif");
copy("setup.php", $AppDir . "setup.php");
copy("Send.php", $AppDir . "Send.php");
copy("MusicDB.php", $AppDir . "MusicDB.php");
copy("QueryAlbum.php", $AppDir . "QueryAlbum.php");
copy("QueryAlbumList.php", $AppDir . "QueryAlbumList.php");
copy("QueryAlphabetPresent.php", $AppDir . "QueryAlphabetPresent.php");
copy("QueryDB.php", $AppDir . "QueryDB.php");
copy("QueryPlayingNowDB.php", $AppDir . "QueryPlayingNowDB.php");
echo "Making sprites and css file in " . $AppDir . $NL;
Make_CSS($musicDB->MaxPreset(), $AppDir . "sprites/sprites.css", $AppDir . "sprites/sprites@2x.css");
$musicDB->close();
copy($DATABASE_FILENAME, $AppDir . $DATABASE_FILENAME);
echo "Finished..." . $NL;
}