本文整理汇总了PHP中FileUtils::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP FileUtils::copy方法的具体用法?PHP FileUtils::copy怎么用?PHP FileUtils::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils::copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: copyContent
public static function copyContent($source, $destination)
{
if (is_dir($source) && $dh = opendir($source)) {
if (!is_dir($destination))
mkdir($destination, 0777);
while (($file = readdir($dh)) !== false) {
if ($file == '.' || $file == '..') {
continue;
} elseif (is_dir($source . DIRECTORY_SEPARATOR . $file)) {
self::copy(
$source . DIRECTORY_SEPARATOR . $file,
$destination . DIRECTORY_SEPARATOR . $file
);
} else {
FileUtils::copy(
$source . DIRECTORY_SEPARATOR . $file,
$destination . DIRECTORY_SEPARATOR . $file
);
}
}
}
}
示例2: run
public function run()
{
$pool = get_object_vars($this->getXmlElement());
if (!is_array($pool['file'])) $pool['file'] = array($pool['file']);
foreach ($pool['file'] as $fileElement) {
$from = (string)$fileElement->attributes()->from;
$to = (string)$fileElement->attributes()->to;
if (!$from || !$to) continue;
if (strpos($to ,'language/')!==false) {
$dirs =
DirUtils::getDirs(
$this->getParentAction()->getBuild()->getPath()
. DIRECTORY_SEPARATOR . 'language'
,
false
);
foreach ($dirs as $dir) {
FileUtils::copy(
$this->
getParentAction()->
getCurrentMod()->
getPath() . DIRECTORY_SEPARATOR . $from
,
$this->
getParentAction()->
getBuild()->
getPath()
.DIRECTORY_SEPARATOR
. preg_replace(
'!language/(\w*)/!iS',
'language/' . $dir . '/',
$to
)
);
}
} elseif (strpos($from, "*") && strpos($to, "*")) {
$from = dirname(
$this->
getParentAction()->
getCurrentMod()->
getPath() . DIRECTORY_SEPARATOR .$from
);
$to = dirname(
$this->
getParentAction()->
getBuild()->
getPath()
.DIRECTORY_SEPARATOR . $to
);
if(is_dir($to)) {
DirUtils::copyContent($from, $to);
} else {
DirUtils::copy($from, $to);
}
} else {
if (
!is_dir(
$this->
getParentAction()->
getCurrentMod()->
getPath() . DIRECTORY_SEPARATOR . $from
)
) {
FileUtils::copy(
$this->
getParentAction()->
getCurrentMod()->
getPath() . DIRECTORY_SEPARATOR . $from
,
$this->
getParentAction()->
getBuild()->
getPath() . DIRECTORY_SEPARATOR . $to
);
} else {
DirUtils::copy(
$this->
getParentAction()->
getCurrentMod()->
getPath() . DIRECTORY_SEPARATOR . $from
,
$this->
getParentAction()->
getBuild()->
getPath() . DIRECTORY_SEPARATOR . $to
);
}
}
}
}