public function writeFile(FilesystemInterface $filesystem, $file, $path)
{
$stream = @fopen($file, 'r');
if ($stream === false) {
return false;
}
$success = false;
$tempPath = $path . '.temp';
$this->deletePath($filesystem, $tempPath);
if ($filesystem->writeStream($tempPath, $stream)) {
$this->deletePath($filesystem, $path);
$success = $filesystem->rename($tempPath, $path);
}
$this->deletePath($filesystem, $tempPath);
fclose($stream);
return $success;
}