Copy a file.

@param PhingFile $src Source path and name file to copy.
@param PhingFile $dest Destination path and name of new file.

@return void

@throws IOException if file cannot be copied.
769608
public function copy(PhingFile $src, PhingFile $dest)
    {
        global $php_errormsg;

        // Recursively copy a directory
        if ($src->isDirectory()) {
            $this->copyr($src->getAbsolutePath(), $dest->getAbsolutePath());
        }

        $srcPath = $src->getAbsolutePath();
        $destPath = $dest->getAbsolutePath();

        if (false === @copy($srcPath, $destPath)) { // Copy FAILED. Log and return err.
            // Add error from php to end of log message. $php_errormsg.
            $msg = "FileSystem::copy() FAILED. Cannot copy $srcPath to $destPath. $php_errormsg";
            throw new IOException($msg);
        }

        $dest->setMode($src->getMode());
    }
339830
public function copyFile($container, $dest_path, $src_container, $src_path, $check_exist = false)
    {
        // does this file already exist?
        if (!$this->fileExists($src_container, $src_path)) {
            throw new NotFoundException("File '$src_path' does not exist.");
        }
        if ($this->fileExists($container, $dest_path)) {
            if (($check_exist)) {
                throw new BadRequestException("File '$dest_path' already exists.");
            }
        }
        // does this file's parent folder exist?
        $parent = FileUtilities::getParentFolder($dest_path);
        if (!empty($parent) && (!$this->folderExists($container, $parent))) {
            throw new NotFoundException("Folder '$parent' does not exist.");
        }

        // create the file
        $this->checkContainerForWrite($container); // need to be able to write to storage
        $this->copyBlob($container, $dest_path, $src_container, $src_path);
    }
623667
protected function copyFileWithDirsCreating($src, $dest)
    {
        $dirPathOfDestFile = dirname($dest);

        if (! File::exists($dirPathOfDestFile)) {
            File::makeDirectory($dirPathOfDestFile, 0755, true);
        }

        if (! File::exists($dest)) {
            File::copy($src, $dest);
        }
    }
104252
public static function copy(string $source, string $dest, bool $overwrite = true): void
	{
		NetteFileSystem::copy($source, $dest, $overwrite);
	}
1186935
public static function copyFile($src, $dst, $newFileMode = null)
    {
        copy($src, $dst);
        if (null !== $newFileMode) {
            @chmod($dst, $newFileMode);
        }
    }
1364427
public function setDestDir($destDir)
    {
        if ($destDir instanceof PhingFile) {
            $this->destDir = $destDir;
        } else {
            $this->destDir = new PhingFile($destDir);
        }
    }
996835
public static function copyRecDir($source, $dest) {
    if (!is_dir($dest)) {
      self::mkdirRec($dest);
    }
    $dir = opendir($source);
    while ($file = readdir($dir)) {
      if ($file == "." || $file == "..") {
        continue;
      }
      self::copyRec("$source/$file", "$dest/$file");
    }
    closedir($dir);
  }
1260983
public static function copyResources($dest, $force, $filename_path, $debug)
    {
        if (file_exists($filename_path)) {
            $destfolder = basename($filename_path);
            if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) {
                if (is_dir($filename_path)) {
                    self::copyr($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
                } else {
                    if (@copy($filename_path, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) {
                        throw new ConfigException("Can't copy " . $filename_path . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder);
                    }
                }
            }
        }
    }
18603
protected void copyFile(File src, File dest, Replacement replaceFn) throws IOException {
        boolean isSource = isSourceFile(src);
        copyFile(src, dest, replaceFn, isSource);
    }
1368258
static function upToDate($src, $dest)
    {
        if (!file_exists($dest)) {
            return false;
        }

        if (filemtime($dest) >= filemtime($src)) {
            return true;
        }
        return false;
    }
309323
private static function copy($src, $dest)
  {
    // If the destination directory does not exist create it
    if(!is_dir($dest)) {
      if(!mkdir($dest,0777,true)) {
        // If the destination directory could not be created stop processing
        echo "Can't create destination path: {$dest}\n";
        return false;
      }
    }
    copy($src, "$dest/" . basename($src));
  }
1059041
public static void copyFile(File srcFile, File destFile) {
		OutputStream out = null;
		InputStream in = null;
		try {
			if (!destFile.getParentFile().exists())
				destFile.getParentFile().mkdirs();

			in = new FileInputStream(srcFile);
			out = new FileOutputStream(destFile);

			// Transfer bytes from in to out
			byte[] buf = new byte[1024];
			int len;
			while ((len = in.read(buf)) > 0) {
				out.write(buf, 0, len);
			}
			in.close();
			out.close();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
166501
public static function copyRec($source, $dest) {
    if (is_file($source)) {
      $perms = fileperms($source);
      return copy($source, $dest) && chmod($dest, $perms);
    }
    if (!is_dir($source)) {
      $message = ObjectFactory::getInstance('message');
      throw new IllegalArgumentException($message->getText("Cannot copy %0% (it's neither a file nor a directory).", [$source]));
    }
    self::copyRecDir($source, $dest);
  }
423510
public static function copyDirectory(string $source, string $dest)
    {
        if (!is_dir($dest)) {
            mkdir($dest, 0700, true);
        }
        if (is_dir($source) && ($dh = opendir($source))) {
            while (($file = readdir($dh)) !== false) {
                if ($file === '.' || $file === '..') {
                    continue;
                } elseif (is_dir("{$source}/{$file}")) {
                    self::copyDirectory("{$source}/{$file}", "{$dest}/{$file}");
                } else {
                    copy("{$source}/{$file}", "{$dest}/{$file}");
                }
            }
            closedir($dh);
        }
    }
60304
public function copy($src, $dest)
    {
        if (is_dir($src)) {
            $this->ensureDir($dest);
            $files = scandir($src);
            foreach ($files as $file) {
                if ($file !== '.' && $file !== '..') {
                    $this->copy($src . '/' . $file, $dest . '/' . $file);
                }
            }
        } else {
            $this->ensureDir(dirname($dest));

            copy($src, $dest);
        }
    }
513987
public static void fileCopy(final File src, final File dest, final boolean overwrite) throws IOException {
        if (!dest.exists() || (dest.exists() && overwrite)) {
            // Create parent directory structure if necessary
            FileUtils.mkParentDirs(dest);

            if (overwrite) {
                Files.copy(src.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
            } else {
                Files.copy(src.toPath(), dest.toPath());
            }
        }
    }
992647
private function recursiveCopy($src, $dst)
    {
        @mkdir($dst, 0755);

        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        foreach ($iterator as $file) {
            if ($file->isDir()) {
                @mkdir($dst.'/'.$iterator->getSubPathName());
            } else {
                $success = copy($file, $dst.'/'.$iterator->getSubPathName());
                if ($success) {
                    if (! $this->silent) {
                        echo 'copied: '.$dst.'/'.$iterator->getSubPathName().PHP_EOL;
                    }
                }
            }
        }
    }