本文整理汇总了PHP中FileUtil::copyDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtil::copyDir方法的具体用法?PHP FileUtil::copyDir怎么用?PHP FileUtil::copyDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtil
的用法示例。
在下文中一共展示了FileUtil::copyDir方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateFile
function updateFile($CopyPath, $AimPath, $BackupPath)
{
FileUtil::copyDir($CopyPath, $AimPath, $overWrite = true, $useBackup = true, $BackupPath);
//删除特殊文件
FileUtil::unlinkFile("../UpgradeSql.sql");
FileUtil::unlinkFile("../SqlLog.txt");
}
示例2: reading_root_init
public static function reading_root_init()
{
if (is_dir(I3GEEK_READING_ROOT . "css/") && file_exists(I3GEEK_READING_ROOT . "qrcode")) {
//完成,没问题
} else {
FileUtil::copyDir(I3GEEK_READING_PLUGIN_ROOT . "reading/css", I3GEEK_READING_ROOT . "css", true);
FileUtil::copyFile(I3GEEK_READING_PLUGIN_ROOT . "reading/qrcode", I3GEEK_READING_ROOT . "qrcode", true);
}
}
示例3: copyDir
/**
* 复制文件夹
*
* @param string $oldDir
* @param string $aimDir
* @param boolean $overWrite 该参数控制是否覆盖原文件
* @return boolean
*/
function copyDir($oldDir, $aimDir, $overWrite = false)
{
$aimDir = str_replace('', '/', $aimDir);
$aimDir = substr($aimDir, -1) == '/' ? $aimDir : $aimDir . '/';
$oldDir = str_replace('', '/', $oldDir);
$oldDir = substr($oldDir, -1) == '/' ? $oldDir : $oldDir . '/';
if (!is_dir($oldDir)) {
return false;
}
if (!file_exists($aimDir)) {
FileUtil::createDir($aimDir);
}
$dirHandle = opendir($oldDir);
while (false !== ($file = readdir($dirHandle))) {
if ($file == '.' || $file == '..') {
continue;
}
if (!is_dir($oldDir . $file)) {
FileUtil::copyFile($oldDir . $file, $aimDir . $file, $overWrite);
} else {
FileUtil::copyDir($oldDir . $file, $aimDir . $file, $overWrite);
}
}
return closedir($dirHandle);
}
示例4: publish
function publish($siteid, $version, $description, $filename, $md5, $type)
{
global $cfg, $data, $versions, $ext;
$rt = array('result' => false, 'error' => -1);
$debug = '1';
$list = getList(false);
$site = $list[$siteid];
//$debug= json_encode($site);
//$debug = $description;
//file_put_contents("debug.log", strtolower(md5_file($filename)))
//file_put_contents("debug.log", strtolower(md5_file($filename)))
if ($site != null && file_exists($filename) && strtolower(md5_file($filename)) == strtolower(trim($md5))) {
if ($site['current_version'] == $version) {
//10 publish 发布版本和线上版本一致
$rt['error'] = 10;
return $rt;
}
//检查目标路径
$p = $site['root'] . $version;
$tmp = $cfg['tmp_unzip'] . getRandomName($siteid . '_' . $version . '_tmp/');
if (file_exists($p)) {
//如果存在则备份配置
//删除已经存在的文件目录
if ($site['backup']) {
backup($p, $site['backup'] . getRandomName($siteid . '_' . $version . '.zip'));
}
$r = delDirAndFile($p);
if ($r == 0) {
$debug = $p;
//9 publish 目录创建失败
$rt['error'] = 9;
}
}
if ($site['upload']) {
//备份上传文件
copy($filename, $site['upload'] . str_replace($cfg['tmp_upload'], '', $filename));
}
if ($rt['error'] == -1) {
if (!mkdir($p) || !mkdir($tmp)) {
//9 publish 目录创建失败
$debug = $p . ' ' . $tmp;
$rt['error'] = 9;
} else {
if ($type && strtolower($type) == 'copyreplace') {
//拷贝当前版本
FileUtil::copyDir($site['root'] . $site['current_version'], $p, true);
}
//解压缩文件到临时目录
$z = new ZipArchive();
//die(file_exists($filename));
$z->open($filename);
$z->extractTo($tmp);
//将临时目录下的deploy目录拷贝到目标路径
if (file_exists($tmp . 'deploy')) {
//将部署程序从deploy目录下拷贝到目标路径
FileUtil::copyDir($tmp . 'deploy', $p, true);
if ($versions[$siteid] == null) {
$versions[$siteid] = array();
}
$intver = intval($version);
$versions[$siteid][$intver] = array('version' => $intver, 'description' => $description, 'date' => date("Y-m-d H:i:s", time()));
save_records($data, $ext, $versions);
$rt['error'] = 0;
$rt['result'] = true;
} else {
$rt['error'] = 7;
$debug = '上传文件无deploy目录';
}
//删除临时目录
/*
FileUtil::unlinkFile($filename);
FileUtil::unlinkDir($tmp);
*/
}
}
} else {
//8 publish upload md5 校验失败
$rt['error'] = 8;
}
$rt['msg'] = $debug;
return $rt;
}
示例5: processingTempFile
private function processingTempFile($urlParam)
{
$file = PATH_ROOT . "/data/update/IBOS " . $urlParam["version"] . " Release[" . $urlParam["release"] . "]/updatelist.tmp";
$authKey = Ibos::app()->setting->get("config/security/authkey");
@unlink($file);
@unlink(PATH_ROOT . "/data/update.php");
Cache::model()->deleteByPk("upgrade_step");
Cache::model()->deleteByPk("upgrade_run");
Setting::model()->updateSettingValueByKey("upgrade", "");
CacheUtil::update();
$randomStr = StringUtil::random(6);
$oldUpdateDir = "/data/update/";
$newUpdateDir = "/data/update-" . $randomStr . "/";
$oldBackDir = "/data/back/";
$newBackDir = "/data/back-" . $randomStr . "/";
FileUtil::copyDir(PATH_ROOT . $oldUpdateDir, PATH_ROOT . $newUpdateDir);
FileUtil::copyDir(PATH_ROOT . $oldBackDir, PATH_ROOT . $newBackDir);
FileUtil::clearDirs(PATH_ROOT . $oldUpdateDir);
FileUtil::clearDirs(PATH_ROOT . $oldBackDir);
$data["step"] = 5;
$data["data"]["msg"] = Ibos::lang("Upgrade successful", "", array("{version}" => "IBOS" . VERSION . " " . VERSION_DATE, "{saveUpdateDir}" => $newUpdateDir, "{saveBackDir}" => $newBackDir));
$this->render("upgradeSuccess", $data);
}