本文整理汇总了PHP中Ethna_Util::purgeDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Ethna_Util::purgeDir方法的具体用法?PHP Ethna_Util::purgeDir怎么用?PHP Ethna_Util::purgeDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ethna_Util
的用法示例。
在下文中一共展示了Ethna_Util::purgeDir方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform
/**
* clear cache files.
*
* @access public
* @todo implement Ethna_Renderer::clear_cache();
* @todo implement Ethna_Plugin_Cachemanager::clear_cache();
* @todo avoid echo, printf
*/
function perform()
{
$r = $this->_getopt(array('basedir=', 'any-tmp-files', 'smarty', 'pear', 'cachemanager'));
if (Ethna::isError($r)) {
return $r;
}
list($args, ) = $r;
$basedir = isset($args['basedir']) ? realpath(end($args['basedir'])) : getcwd();
$controller = Ethna_Handle::getAppController($basedir);
if (Ethna::isError($controller)) {
return $controller;
}
$tmp_dir = $controller->getDirectory('tmp');
if (isset($args['smarty']) || isset($args['any-tmp-files'])) {
echo "cleaning smarty caches, compiled templates...";
$renderer = $controller->getRenderer();
if (strtolower(get_class($renderer)) == "ethna_renderer_smarty") {
$renderer->getEngine()->clear_all_cache();
$renderer->getEngine()->clear_compiled_tpl();
}
echo " done\n";
}
if (isset($args['cachemanager']) || isset($args['any-tmp-files'])) {
echo "cleaning Ethna_Plugin_Cachemanager caches...";
$cache_dir = sprintf("%s/cache", $tmp_dir);
Ethna_Util::purgeDir($cache_dir);
echo " done\n";
}
if (isset($args['any-tmp-files'])) {
echo "cleaning tmp dirs...";
// purge only entries in tmp.
if ($dh = opendir($tmp_dir)) {
while (($entry = readdir($dh)) !== false) {
if ($entry === '.' || $entry === '..') {
continue;
}
Ethna_Util::purgeDir("{$tmp_dir}/{$entry}");
}
closedir($dh);
}
echo " done\n";
}
return true;
}
示例2: fopen
/**
* @access private
*/
function &_makePackage($skelfile, $setting, $workdir)
{
if (Ethna_Util::mkdir($workdir, 0755) === false) {
return Ethna::raiseError("failed making working dir: {$workdir}.");
}
// プラグインの元ファイルを作成
$rfp = fopen($skelfile, "r");
if ($rfp == false) {
return Ethna::raiseError("failed open skelton file: {$skelfile}.");
}
$outputfile = $setting['filename'];
$wfp = fopen("{$workdir}/{$outputfile}", "w");
if ($rfp == false) {
fclose($rfp);
return Ethna::raiseError("failed creating working file: {$outputfile}.");
}
for (;;) {
$s = fread($rfp, 4096);
if (strlen($s) == 0) {
break;
}
foreach ($setting['macro'] as $k => $v) {
$s = preg_replace("/{\\\${$k}}/", $v, $s);
}
fwrite($wfp, $s);
}
fclose($wfp);
fclose($rfp);
// package.xml を作る
$pkgconfig = array('packagedirectory' => $workdir, 'outputdirectory' => $workdir, 'ignore' => array('CVS/', '.cvsignore', '.svn/', 'package.xml', 'package.ini', $setting['pkgname'] . '-*.tgz'), 'filelistgenerator' => 'file', 'changelogoldtonew' => false);
$packagexml =& new PEAR_PackageFileManager2();
$pkgconfig = array_merge($pkgconfig, $setting['config']);
$packagexml->setOptions($pkgconfig);
$packagexml->setPackage($setting['pkgname']);
$packagexml->setSummary($setting['summary']);
$packagexml->setNotes($setting['notes']);
$packagexml->setDescription($setting['description']);
$packagexml->setChannel($setting['channel']);
$packagexml->setAPIVersion($setting['version']);
$packagexml->setReleaseVersion($setting['version']);
$packagexml->setReleaseStability($setting['state']);
$packagexml->setAPIStability($setting['state']);
$packagexml->setPackageType('php');
foreach ($setting['maintainers'] as $m) {
$packagexml->addMaintainer($m['role'], $m['user'], $m['name'], $m['email'], $m['active']);
}
$packagexml->setLicense($setting['license']['name'], $setting['license']['uri']);
$packagexml->addRole('css', 'php');
$packagexml->addRole('tpl', 'php');
$packagexml->addRole('ethna', 'php');
$packagexml->addRole('sh', 'script');
$packagexml->addRole('bat', 'script');
$packagexml->setPhpDep('4.1.0');
$packagexml->setPearinstallerDep('1.3.5');
$packagexml->generateContents();
foreach ($setting['callback'] as $method => $params) {
$r = call_user_func_array(array(&$packagexml, $method), $params);
}
$r = $packagexml->writePackageFile();
if (PEAR::isError($r)) {
return Ethna::raiseError($r->getMessage, $r->getCode());
}
// package を作る
$r = $this->pear->_run('package', array(), array("{$workdir}/package.xml"));
if (PEAR::isError($r)) {
return Ethna::raiseError($r->getMessage, $r->getCode());
}
if (Ethna_Util::purgeDir($workdir) === false) {
return Ethna::raiseError("failed cleaning up working dir: {$workdir}.");
}
}
示例3: perform
/**
* @access public
* @todo deal with the package including some plugins.
*/
public function perform()
{
$true = true;
// check arguments.
$args = $this->_parseArgList();
if (Ethna::isError($args)) {
return Ethna::raiseError($args->getMessage(), 'usage');
}
$basedir = isset($args['basedir']) ? realpath($args['basedir']) : getcwd();
$channel = isset($args['channel']) ? $args['channel'] : 'dummy';
$pear_local = new Ethna_PearConfig_Local();
$r = $pear_local->init('local', $basedir, $channel);
if (Ethna::isError($r)) {
return $r;
}
// build command string.
$pear_cmds = $args['pear_args'];
$pear_bin = ETHNA_OS_WINDOWS ? getenv('PHP_PEAR_BIN_DIR') . DIRECTORY_SEPARATOR . 'pear.bat' : PHP_BINDIR . DIRECTORY_SEPARATOR . 'pear';
$local_conf_file = $pear_local->getConfFile();
array_unshift($pear_cmds, $pear_bin, '-c', $local_conf_file);
if (ETHNA_OS_WINDOWS) {
foreach ($pear_cmds as $key => $value) {
$pear_cmds[$key] = strpos($value, ' ') !== false ? '"' . $value . '"' : $value;
}
}
$command_str = implode(' ', $pear_cmds);
// finally exec pear command.
if (ETHNA_OS_WINDOWS) {
$tmp_dir_name = "ethna_tmp_dir";
Ethna_Util::mkdir($tmp_dir_name, 0777);
$tmpnam = tempnam($tmp_dir_name, "temp") . '.bat';
$fp = fopen($tmpnam, 'w');
fwrite($fp, "@echo off\r\n");
fwrite($fp, $command_str . " 2>&1");
fclose($fp);
system($tmpnam);
Ethna_Util::purgeDir($tmp_dir_name);
} else {
system($command_str);
}
return $true;
}
示例4: purgeDir
/**
* ディレクトリを再帰的に削除する
* (途中で失敗しても中断せず、削除できるものはすべて消す)
*
* @access public
* @param string $file 削除するファイルまたはディレクトリ
* @return bool true:成功 false:失敗
* @static
*/
public static function purgeDir($dir)
{
if (file_exists($dir) === false) {
return false;
}
if (is_dir($dir) === false) {
return unlink($dir);
}
$dh = opendir($dir);
if ($dh === false) {
return false;
}
$ret = true;
while (($entry = readdir($dh)) !== false) {
if ($entry === '.' || $entry === '..') {
continue;
}
$ret = $ret && Ethna_Util::purgeDir("{$dir}/{$entry}");
}
closedir($dh);
if ($ret) {
return rmdir($dir);
} else {
return false;
}
}
示例5: delete
function delete()
{
Ethna_Util::purgeDir($this->proj_basedir);
}