src/Ace/Commands/Core/BuildCommand.php
/**
	 * Deletes the specified directory and all files within it. Careful!
	 *
	 * @param string $dirPath
	 * @return void
	 */
Deletes the specified directory and all files within it. Careful.
@param string $dirPath
@return void
Deletes the specified directory and all files within it . Careful . @param string $dirPath @return void
protected function deleteDir($dirPath) {
		if (!is_dir($dirPath)) {
			throw new InvalidArgumentException("$dirPath is not a directory");
		}
		if (!is_writable($dirPath)) {
			throw new InvalidArgumentException("$dirPath cannot be deleted due to permissions");
		}
		if (!starts_with($dirPath, Application::root(), true)) {
			throw new InvalidArgumentException("$dirPath is outside of the application");
		}
		$dirPath = rtrim($dirPath, '/\\') . DIRECTORY_SEPARATOR;
		$files = glob($dirPath . '*', GLOB_MARK);
		foreach ($files as $file) {
			if (is_dir($file)) {
				$this->deleteDir($file);
			}
			else if (is_writable($file)) {
				unlink($file);
			}
			else {
				throw new Exception("$file cannot be deleted due to permissions");
			}
		}
		rmdir($dirPath);
	}
protected function deleteDir ( $ dirPath ) { if ( ! is_dir ( $ dirPath ) ) { throw new InvalidArgumentException ( " $ dirPath  is not a directory " ) ; } if ( ! is_writable ( $ dirPath ) ) { throw new InvalidArgumentException ( " $ dirPath  cannot be deleted due to permissions " ) ; } if ( ! starts_with ( $ dirPath , Application :: root ( ) , true ) ) { throw new InvalidArgumentException ( " $ dirPath  is outside of the application " ) ; } $ dirPath = rtrim ( $ dirPath , '/\\' ) . DIRECTORY_SEPARATOR ; $ files = glob ( $ dirPath . '*' , GLOB_MARK ) ; foreach ( $ files as $ file ) { if ( is_dir ( $ file ) ) { $ this -> deleteDir ( $ file ) ; } else if ( is_writable ( $ file ) ) { unlink ( $ file ) ; } else { throw new Exception ( " $ file  cannot be deleted due to permissions " ) ; } } rmdir ( $ dirPath ) ; }
Deletes the specified directory and all files within it.
Deletes the specified directory and all files within it .