/** * Tests the recursive delete implementation works also for directories with * linked contents. * * @return void */ public function testDeleteDirectoryWithLinksAndSymlinks() { if (!function_exists('link') || !function_exists('symlink')) { $this->markTestSkipped('Missing "link" or "symlink" function.'); return; } $this->createTestDirectories(array('/logs/foo/12345')); $this->createTestFile('/logs/foo/12345/bar.txt'); $file = PHPUC_TEST_DIR . '/logs/foo/12345/bar.txt'; link($file, PHPUC_TEST_DIR . '/logs/bar.txt'); symlink($file, PHPUC_TEST_DIR . '/logs/foo/bar.txt'); phpucFileUtil::deleteDirectory(PHPUC_TEST_DIR . '/logs'); $this->assertFileNotExists(PHPUC_TEST_DIR . '/logs'); }
/** * Removes all project artifact subdirectories that match one of the given * timestamps. * * @param string $basePath * Base directory where the method starts to clean up. * @param array $timestamps * List of all removable timestamps. * * @return void */ protected function cleanArtifacts($basePath, array $timestamps) { foreach ($timestamps as $timestamp) { $path = "{$basePath}/{$timestamp}"; if (is_dir($path)) { phpucFileUtil::deleteDirectory($path); } } }
/** * Deletes the project directory for the context project. * * @param string $installDir * The CruiseControl installation directory. * @param string $projectName * The project name. * * @return void */ protected function deleteProjectDirectory($installDir, $projectName) { $artifacts = "{$installDir}/projects/{$projectName}"; if (is_dir($artifacts)) { phpucFileUtil::deleteDirectory($artifacts); } }