本文整理汇总了PHP中CRM_Utils_File::copyDir方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_File::copyDir方法的具体用法?PHP CRM_Utils_File::copyDir怎么用?PHP CRM_Utils_File::copyDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_File
的用法示例。
在下文中一共展示了CRM_Utils_File::copyDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moveFiles
public function moveFiles($id, $key, $deleteOrginal = false)
{
$e = self::$_extensions;
if ($e['per_id'][$id]['status'] === 'uploaded') {
require_once 'CRM/Utils/File.php';
CRM_Utils_File::copyDir($e['per_id'][$id]['path'], $this->extDir . DIRECTORY_SEPARATOR . $e['per_id'][$id]['type'] . DIRECTORY_SEPARATOR . $e['per_id'][$id]['key']);
if ($deleteOrginal) {
$this->deleteFiles($id, $key);
}
}
}
示例2: replaceDir
/**
* Move $fromDir to $toDir, replacing/deleting any
* pre-existing content.
*
* @param string $fromDir
* The directory which should be moved.
* @param string $toDir
* The new location of the directory.
* @param bool $verbose
*
* @return bool
* TRUE on success
*/
public static function replaceDir($fromDir, $toDir, $verbose = FALSE)
{
if (is_dir($toDir)) {
if (!self::cleanDir($toDir, TRUE, $verbose)) {
return FALSE;
}
}
// return rename($fromDir, $toDir); CRM-11987, https://bugs.php.net/bug.php?id=54097
CRM_Utils_File::copyDir($fromDir, $toDir);
if (!CRM_Utils_File::cleanDir($fromDir, TRUE, FALSE)) {
CRM_Core_Session::setStatus(ts('Failed to clean temp dir: %1', array(1 => $fromDir)), '', 'alert');
return FALSE;
}
return TRUE;
}
示例3: copyDir
public function copyDir($source, $destination)
{
$dir = opendir($source);
@mkdir($destination);
while (FALSE !== ($file = readdir($dir))) {
if ($file != '.' && $file != '..') {
if (is_dir($source . DIRECTORY_SEPARATOR . $file)) {
CRM_Utils_File::copyDir($source . DIRECTORY_SEPARATOR . $file, $destination . DIRECTORY_SEPARATOR . $file);
} else {
copy($source . DIRECTORY_SEPARATOR . $file, $destination . DIRECTORY_SEPARATOR . $file);
}
}
}
closedir($dir);
}
示例4: installFiles
public function installFiles()
{
$config = CRM_Core_Config::singleton();
$zip = new ZipArchive();
$res = $zip->open($this->tmpFile);
if ($res === TRUE) {
$zipSubDir = CRM_Utils_Zip::guessBasedir($zip, $this->key);
if ($zipSubDir === FALSE) {
CRM_Core_Session::setStatus(ts('Unable to extract the extension: bad directory structure') . '<br/>');
return FALSE;
}
$path = $config->extensionsDir . DIRECTORY_SEPARATOR . 'tmp';
$extractedZipPath = $path . DIRECTORY_SEPARATOR . $zipSubDir;
if (is_dir($extractedZipPath)) {
if (!CRM_Utils_File::cleanDir($extractedZipPath, TRUE, FALSE)) {
CRM_Core_Session::setStatus(ts('Unable to extract the extension: %1 cannot be cleared', array(1 => $extractedZipPath)) . '<br/>');
return FALSE;
}
}
if (!$zip->extractTo($path)) {
CRM_Core_Session::setStatus(ts('Unable to extract the extension to %1.', array(1 => $path)) . '<br/>');
return FALSE;
}
$zip->close();
} else {
CRM_Core_Session::setStatus('Unable to extract the extension.');
return FALSE;
}
$filename = $extractedZipPath . DIRECTORY_SEPARATOR . 'info.xml';
if (!is_readable($filename)) {
CRM_Core_Session::setStatus(ts('Failed reading data from %1 during installation', array(1 => $filename)) . '<br/>');
return FALSE;
}
$newxml = file_get_contents($filename);
if (empty($newxml)) {
CRM_Core_Session::setStatus(ts('Failed reading data from %1 during installation', array(1 => $filename)) . '<br/>');
return FALSE;
}
$check = new CRM_Core_Extensions_Extension($this->key . ".newversion");
$check->readXMLInfo($newxml);
if ($check->version != $this->version) {
CRM_Core_Error::fatal('Cannot install - there are differences between extdir XML file and archive XML file!');
}
// Why is this a copy instead of a move?
CRM_Utils_File::copyDir($extractedZipPath, $config->extensionsDir . DIRECTORY_SEPARATOR . $this->key);
if (!CRM_Utils_File::cleanDir($extractedZipPath, TRUE, FALSE)) {
CRM_Core_Session::setStatus(ts('Failed to clean temp dir: %1', array(1 => $extractedZipPath)) . '<br/>');
}
return TRUE;
}