function Cache::copyTo
Copy a file out of the cache
Return value
bool
File
-
vendor/
composer/ composer/ src/ Composer/ Cache.php, line 212
Class
- Cache
- Reads/writes to a filesystem cache
Namespace
ComposerCode
public function copyTo(string $file, string $target) {
if ($this->isEnabled()) {
$file = Preg::replace('{[^' . $this->allowlist . ']}i', '-', $file);
if (file_exists($this->root . $file)) {
try {
touch($this->root . $file, (int) filemtime($this->root . $file), time());
} catch (\ErrorException $e) {
// fallback in case the above failed due to incorrect ownership
// see https://github.com/composer/composer/issues/4070
Silencer::call('touch', $this->root . $file);
}
$this->io
->writeError('Reading ' . $this->root . $file . ' from cache', true, IOInterface::DEBUG);
return $this->filesystem
->copy($this->root . $file, $target);
}
}
return false;
}