public static function delete( $path ) {
		if ( !is_dir( $path ) ) { // already deleted
			return;
		}
		$files = scandir( $path );
		if ( !$files ) {
			throw new GpgLibException( "Tried to delete temporary directory $path but could not find it" );
		}
		foreach ( $files as $file ) {
			if ( $file === '.' || $file === '..' ) {
				continue;
			}
			$file = $path . DIRECTORY_SEPARATOR . $file;
			$ok = unlink( $file );
			if ( !$ok ) {
				throw new GpgLibException( "Could not delete $file" );
			}
		}
		$ok = rmdir( $path );
		if ( !$ok ) {
			throw new GpgLibException( "Could not delete $path" );
		}
	}