protected function copyFile($fromFullPath, $toFullPath, $replace = false) { $this->createDirectory(dirname($toFullPath)); if ($replace) { $this->filesystem->delete($toFullPath); } if (!$this->filesystem->copy($fromFullPath, $toFullPath)) { throw new CommandErrorException('File cannot be copied to the path ' . $toFullPath); } }
/** * Copy file into another file * * @param string $source source file path * @param string $target target directory path * @param string $name new file name * @return string|bool **/ protected function _copy($source, $target, $name) { $path = $this->_joinPath($target, $name); if ($this->fs->copy($source, $path) === false) { return false; } return $path; }
/** * Copy a file. * * @param string $source * @param string $destination * @throws IoWriteException */ public function copy($source, $destination) { try { $this->fs->copy($source, $destination); } catch (Error $ex) { throw new IoWriteException("File {$source} could not have benn copied to {$destination}.", $ex); } catch (Exception $ex) { throw new IoWriteException("File {$source} could not have benn copied to {$destination}.", $ex); } }
/** * @param string $trimmedSourcePath * @param string $trimmedTargetPath * @return bool */ protected function copyFolderRecursively($trimmedSourcePath, $trimmedTargetPath) { try { $contents = $this->filesystem->listContents($trimmedSourcePath, true); foreach ($contents as $item) { if ('file' === $item['type']) { try { $relPath = substr_replace($trimmedSourcePath, '', 0, strlen($item['path'])); $targetPath = $trimmedTargetPath . $relPath . '/' . $item['basename']; $this->filesystem->copy($item['path'], $targetPath); } catch (FileExistsException $fee) { continue; } catch (FileNotFoundException $fnfe) { return false; } } } } catch (\Exception $e) { return false; } return true; }
/** * Copy a file to a new location. * * @param string $from * @param string $to * @return bool */ public function copy($from, $to) { return $this->driver->copy($from, $to); }
/** * Copy file into another file * * @param string $source source file path * @param string $target target directory path * @param string $name new file name * @return bool **/ protected function _copy($source, $target, $name) { return $this->fs->copy($source, $this->_joinPath($target, $name)); }
/** * Move a file to a new location. * * @param string $from * @param string $to * @return bool */ public function move($from, $to) { $this->driver->copy($from, $to); $this->driver->delete($from); }
/** * Copy file into another file * * @param string $source source file path * @param string $target target directory path * @param string $name new file name * @return string|bool **/ protected function _copy($source, $target, $name) { $path = $this->_joinPath($target, $name); return $this->_resultPath($this->fs->copy($source, $path), $path); }
/** * Copy a file. * * @param string $path Path to the existing file. * @param string $newpath The new path of the file. * * @throws FileExistsException Thrown if $newpath exists. * @throws FileNotFoundException Thrown if $path does not exist. * * @return bool True on success, false on failure. */ public function copy($path, $newpath) { return $this->fileSystem->copy($path, $newpath); }