function Cache::copyFrom
Copy a file into the cache
Return value
bool
File
-
vendor/
composer/ composer/ src/ Composer/ Cache.php, line 189
Class
- Cache
- Reads/writes to a filesystem cache
Namespace
ComposerCode
public function copyFrom(string $file, string $source) {
if ($this->isEnabled() && !$this->readOnly) {
$file = Preg::replace('{[^' . $this->allowlist . ']}i', '-', $file);
$this->filesystem
->ensureDirectoryExists(dirname($this->root . $file));
if (!file_exists($source)) {
$this->io
->writeError('<error>' . $source . ' does not exist, can not write into cache</error>');
}
elseif ($this->io
->isDebug()) {
$this->io
->writeError('Writing ' . $this->root . $file . ' into cache from ' . $source);
}
return $this->filesystem
->copy($source, $this->root . $file);
}
return false;
}