本文整理汇总了PHP中FileSystem::copy方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::copy方法的具体用法?PHP FileSystem::copy怎么用?PHP FileSystem::copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::copy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeLearningMaterialFile
/**
* Store a learning material file and return the relativePath
* @param File $file
* @param boolean $preserveOriginalFile
* @return string $relativePath
*/
public function storeLearningMaterialFile(File $file, $preserveOriginalFile = true)
{
$relativePath = $this->getLearningMaterialFilePath($file);
$fullPath = $this->getPath($relativePath);
$dir = dirname($fullPath);
$this->fileSystem->mkdir($dir);
if ($preserveOriginalFile) {
$this->fileSystem->copy($file->getPathname(), $fullPath, false);
} else {
if (!$this->fileSystem->exists($fullPath)) {
$this->fileSystem->rename($file->getPathname(), $fullPath);
}
}
return $relativePath;
}
示例2: deepCopy
public static function deepCopy($src, $dest, array $patternMatch = null)
{
$fileSystem = new FileSystem();
if (!$fileSystem->exists($src)) {
return;
}
if (!$fileSystem->exists($dest)) {
$fileSystem->mkdir($dest, 0777);
}
$match = false;
if (!empty($patternMatch) && count($patternMatch) == 2) {
$match = true;
}
$fileCount = 0;
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($src, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $path) {
if ($match && $patternMatch[0]->{$patternMatch}[1]($path->getPathname())) {
continue;
}
$relativeFile = str_replace($src, '', $path->getPathname());
$destFile = $dest . $relativeFile;
if ($path->isDir()) {
if (!$fileSystem->exists($destFile)) {
$fileSystem->mkdir($destFile, 0777);
}
} else {
if (strpos($path->getFilename(), ".") === 0) {
continue;
}
$fileSystem->copy($path->getPathname(), $destFile, true);
$fileCount++;
}
}
return $fileCount;
}
示例3: copyFile
/**
* @param $origin file path
* @param $destinationDirectory destination directory path
* @return StandardResponseInterface
*/
public function copyFile($origin, $destinationDirectory)
{
$fullPath = $this->getRealPath($origin);
$fullDestinationPath = $this->getRealPath($destinationDirectory);
$this->fs->copy($fullPath, $fullDestinationPath . '/' . basename($fullPath));
return new StandardResponse();
}
示例4: copy
/**
* Copy a file, takes care of symbolic links
*
* @param PhingFile $src Source path and name file to copy.
* @param PhingFile $dest Destination path and name of new file.
*
* @return void
* @throws Exception if file cannot be copied.
*/
function copy(PhingFile $src, PhingFile $dest)
{
global $php_errormsg;
if (!$src->isLink()) {
return parent::copy($src, $dest);
}
$srcPath = $src->getAbsolutePath();
$destPath = $dest->getAbsolutePath();
$linkTarget = $src->getLinkTarget();
if (false === @symlink($linkTarget, $destPath)) {
$msg = "FileSystem::copy() FAILED. Cannot create symlink from {$destPath} to {$linkTarget}.";
throw new Exception($msg);
}
}
示例5: protectDirectory
/**
* Installs .htaccess and web.config to the given path
*
* @param string $path
*/
public static function protectDirectory($path)
{
$templatesLocation = __DIR__ . "/../Initialization";
FileSystem::copy("{$templatesLocation}/.htaccess.tpl", "{$path}/.htaccess");
FileSystem::copy("{$templatesLocation}/web.tpl.config", "{$path}/web.config");
}