本文整理汇总了PHP中RecursiveIteratorIterator::getPathName方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::getPathName方法的具体用法?PHP RecursiveIteratorIterator::getPathName怎么用?PHP RecursiveIteratorIterator::getPathName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecursiveIteratorIterator
的用法示例。
在下文中一共展示了RecursiveIteratorIterator::getPathName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _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);
}
}
示例4: 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();
}
}
示例5: 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));
}
}
示例6: Phar
$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();
rename($pharFilename, $binaryFilename);
示例7: MakePlaylists
function MakePlaylists($TopDirectory)
{
global $NL;
$Cnt = 0;
$DirPlaylist = new Playlist();
try {
foreach ($TopDirectory as $Dir => $RootMenuNo) {
$it = new RecursiveIteratorIterator(new RecursiveDirectoryReader($Dir), RecursiveIteratorIterator::SELF_FIRST);
while ($it->valid()) {
//echo $it->getPathName().$NL;
if ($DirPlaylist->PlaylistDir($it->getPathName())) {
$Cnt++;
}
$it->next();
}
}
} catch (Exception $e) {
echo 'No files Found!' . $NL;
}
return $Cnt;
}
示例8: 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;
}