Improved the PHPdoc of FileSystem::copy()
This commit is contained in:
parent
2a2aefa4b7
commit
9ad67caea5
|
@ -23,17 +23,17 @@ class Filesystem
|
||||||
/**
|
/**
|
||||||
* Copies a file.
|
* Copies a file.
|
||||||
*
|
*
|
||||||
* This method only copies the file if the origin file is newer than the target file.
|
* If the target file is older than the origin file, it's always overwritten.
|
||||||
|
* If the target file is newer, it is overwritten only when the
|
||||||
|
* $overwriteNewerFiles option is set to true.
|
||||||
*
|
*
|
||||||
* By default, if the target already exists, it is not overridden.
|
* @param string $originFile The original filename
|
||||||
*
|
* @param string $targetFile The target filename
|
||||||
* @param string $originFile The original filename
|
* @param bool $overwriteNewerFiles If true, target files newer than origin files are overwritten
|
||||||
* @param string $targetFile The target filename
|
|
||||||
* @param bool $override Whether to override an existing file or not
|
|
||||||
*
|
*
|
||||||
* @throws IOException When copy fails
|
* @throws IOException When copy fails
|
||||||
*/
|
*/
|
||||||
public function copy($originFile, $targetFile, $override = false)
|
public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
|
||||||
{
|
{
|
||||||
if (stream_is_local($originFile) && !is_file($originFile)) {
|
if (stream_is_local($originFile) && !is_file($originFile)) {
|
||||||
throw new IOException(sprintf('Failed to copy %s because file not exists', $originFile));
|
throw new IOException(sprintf('Failed to copy %s because file not exists', $originFile));
|
||||||
|
@ -42,7 +42,7 @@ class Filesystem
|
||||||
$this->mkdir(dirname($targetFile));
|
$this->mkdir(dirname($targetFile));
|
||||||
|
|
||||||
$doCopy = true;
|
$doCopy = true;
|
||||||
if (!$override && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
|
if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
|
||||||
$doCopy = filemtime($originFile) > filemtime($targetFile);
|
$doCopy = filemtime($originFile) > filemtime($targetFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue