/** * @test */ public function copyDirectoryRecursivelyKeepsExistingTargetFilesIfRequested() { Files::createDirectoryRecursively('vfs://Foo/source/bar/baz'); file_put_contents('vfs://Foo/source/bar/baz/file.txt', 'source content'); Files::createDirectoryRecursively('vfs://Foo/target/bar/baz'); file_put_contents('vfs://Foo/target/bar/baz/file.txt', 'target content'); Files::copyDirectoryRecursively('vfs://Foo/source', 'vfs://Foo/target', true); $this->assertEquals('target content', file_get_contents('vfs://Foo/target/bar/baz/file.txt')); }
/** * Copies any distribution files to their place if needed. * * @param string $installerResourcesDirectory Path to the installer directory that contains the Distribution/Essentials and/or Distribution/Defaults directories. * @return void */ protected static function copyDistributionFiles($installerResourcesDirectory) { $essentialsPath = $installerResourcesDirectory . 'Distribution/Essentials'; if (is_dir($essentialsPath)) { Files::copyDirectoryRecursively($essentialsPath, Files::getUnixStylePath(getcwd()) . '/', false, true); } $defaultsPath = $installerResourcesDirectory . 'Distribution/Defaults'; if (is_dir($defaultsPath)) { Files::copyDirectoryRecursively($defaultsPath, Files::getUnixStylePath(getcwd()) . '/', true, true); } }
/** * Moves a package from one path to another. * * @param string $fromAbsolutePath * @param string $toAbsolutePath * @return void */ protected function movePackage($fromAbsolutePath, $toAbsolutePath) { Files::createDirectoryRecursively($toAbsolutePath); Files::copyDirectoryRecursively($fromAbsolutePath, $toAbsolutePath, false, true); Files::removeDirectoryRecursively($fromAbsolutePath); }