From bd4e76e996c7d99820dd884cea104276d4ee9861 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Mon, 2 Sep 2024 17:52:57 +0200 Subject: [PATCH] refactor(common-utils)!: Remove the `force` argument from delete functions The new implementation always applies force, which is also covered by a test, so this code became obsolete. Signed-off-by: Sebastian Schuberth --- .../src/test/kotlin/OrtPackageNamingTest.kt | 2 +- downloader/src/main/kotlin/Downloader.kt | 18 +++++++++--------- downloader/src/main/kotlin/WorkingTreeCache.kt | 2 +- .../VerifySourceArtifactCurationsCommand.kt | 2 +- model/src/main/kotlin/utils/FileArchiver.kt | 2 +- .../main/kotlin/UploadResultToSw360Command.kt | 2 +- .../conan/src/main/kotlin/Conan.kt | 4 ++-- .../gradle/src/main/kotlin/Gradle.kt | 2 +- .../maven/src/funTest/kotlin/MavenFunTest.kt | 2 +- .../src/main/kotlin/utils/NuGetInspector.kt | 4 ++-- .../kotlin/utils/PythonInspectorFunTest.kt | 4 ++-- .../python/src/main/kotlin/Pip.kt | 2 +- .../python/src/main/kotlin/Poetry.kt | 2 +- .../src/main/kotlin/utils/PythonInspector.kt | 2 +- .../sbt/src/main/kotlin/Sbt.kt | 2 +- .../main/kotlin/utils/SpdxResolvedDocument.kt | 2 +- .../boyterlc/src/main/kotlin/BoyterLc.kt | 2 +- .../scanners/dos/src/main/kotlin/DosScanner.kt | 2 +- .../scancode/src/main/kotlin/ScanCode.kt | 2 +- scanner/src/main/kotlin/Scanner.kt | 4 ++-- .../kotlin/provenance/ProvenanceDownloader.kt | 2 +- .../src/main/kotlin/storages/Sw360Storage.kt | 4 ++-- .../src/main/kotlin/utils/FileListResolver.kt | 2 +- .../kotlin/SafeDeleteRecursivelyFunTest.kt | 6 +++--- utils/common/src/main/kotlin/ArchiveUtils.kt | 2 +- utils/common/src/main/kotlin/Extensions.kt | 9 ++++----- 26 files changed, 44 insertions(+), 45 deletions(-) diff --git a/detekt-rules/src/test/kotlin/OrtPackageNamingTest.kt b/detekt-rules/src/test/kotlin/OrtPackageNamingTest.kt index 2e3d15e299b03..66c9f2b4436be 100644 --- a/detekt-rules/src/test/kotlin/OrtPackageNamingTest.kt +++ b/detekt-rules/src/test/kotlin/OrtPackageNamingTest.kt @@ -154,7 +154,7 @@ private fun TestConfiguration.createFile(dir: String, content: String): File { val parent = File("build/classes/kotlin/test/$dir").safeMkdirs() afterTest { - parent.safeDeleteRecursively(force = true) + parent.safeDeleteRecursively() } return File(parent, "Test.kt").apply { writeText(content) } diff --git a/downloader/src/main/kotlin/Downloader.kt b/downloader/src/main/kotlin/Downloader.kt index 8917da2b7b5d2..b34168f715ec1 100644 --- a/downloader/src/main/kotlin/Downloader.kt +++ b/downloader/src/main/kotlin/Downloader.kt @@ -128,8 +128,8 @@ class Downloader(private val config: DownloaderConfiguration) { "took ${vcsMark.elapsedNow()}." } - // Clean up any left-over files (force to delete read-only files in ".git" directories on Windows). - outputDirectory.safeDeleteRecursively(force = true, baseDirectory = outputDirectory) + // Clean up any left-over files. + outputDirectory.safeDeleteRecursively(baseDirectory = outputDirectory) exception.addSuppressed(e) } @@ -169,7 +169,7 @@ class Downloader(private val config: DownloaderConfiguration) { } // Clean up any left-over files. - outputDirectory.safeDeleteRecursively(force = true, baseDirectory = outputDirectory) + outputDirectory.safeDeleteRecursively(baseDirectory = outputDirectory) exception.addSuppressed(e) } @@ -283,7 +283,7 @@ class Downloader(private val config: DownloaderConfiguration) { } // Clean up any files left from the failed VCS download (i.e. a ".git" directory). - outputDirectory.safeDeleteRecursively(force = true, baseDirectory = outputDirectory) + outputDirectory.safeDeleteRecursively(baseDirectory = outputDirectory) val fallbackPkg = pkg.copy(vcsProcessed = pkg.vcsProcessed.copy(url = vcsUrlNoCredentials)) applicableVcs.download(fallbackPkg, outputDirectory, config.allowMovingRevisions, recursive) @@ -331,7 +331,7 @@ class Downloader(private val config: DownloaderConfiguration) { } else { tempDir = createOrtTempDir() okHttpClient.downloadFile(sourceArtifact.url, tempDir).getOrElse { - tempDir.safeDeleteRecursively(force = true) + tempDir.safeDeleteRecursively() throw DownloadException("Failed to download source artifact from ${sourceArtifact.url}.", it) } } @@ -354,7 +354,7 @@ class Downloader(private val config: DownloaderConfiguration) { "Cannot verify source artifact with ${sourceArtifact.hash}, skipping verification." } } else if (!sourceArtifact.hash.verify(sourceArchive)) { - tempDir?.safeDeleteRecursively(force = true) + tempDir?.safeDeleteRecursively() throw DownloadException("Source artifact does not match expected ${sourceArtifact.hash}.") } } @@ -369,7 +369,7 @@ class Downloader(private val config: DownloaderConfiguration) { sourceArchive.unpack(gemDirectory) dataFile.unpack(outputDirectory) } finally { - gemDirectory.safeDeleteRecursively(force = true) + gemDirectory.safeDeleteRecursively() } } else { sourceArchive.unpackTryAllTypes(outputDirectory) @@ -379,7 +379,7 @@ class Downloader(private val config: DownloaderConfiguration) { "Could not unpack source artifact '${sourceArchive.absolutePath}': ${e.collectMessages()}" } - tempDir?.safeDeleteRecursively(force = true) + tempDir?.safeDeleteRecursively() throw DownloadException(e) } @@ -387,7 +387,7 @@ class Downloader(private val config: DownloaderConfiguration) { "Successfully unpacked ${sourceArtifact.url} to '${outputDirectory.absolutePath}'..." } - tempDir?.safeDeleteRecursively(force = true) + tempDir?.safeDeleteRecursively() return ArtifactProvenance(sourceArtifact) } } diff --git a/downloader/src/main/kotlin/WorkingTreeCache.kt b/downloader/src/main/kotlin/WorkingTreeCache.kt index 150081f04617a..ff86170257268 100644 --- a/downloader/src/main/kotlin/WorkingTreeCache.kt +++ b/downloader/src/main/kotlin/WorkingTreeCache.kt @@ -97,7 +97,7 @@ class DefaultWorkingTreeCache : WorkingTreeCache { "${getRevision()} ..." } - getRootPath().safeDeleteRecursively(force = true) + getRootPath().safeDeleteRecursively() } } } diff --git a/helper-cli/src/main/kotlin/commands/VerifySourceArtifactCurationsCommand.kt b/helper-cli/src/main/kotlin/commands/VerifySourceArtifactCurationsCommand.kt index bf345446ae6ed..408e8a426f84b 100644 --- a/helper-cli/src/main/kotlin/commands/VerifySourceArtifactCurationsCommand.kt +++ b/helper-cli/src/main/kotlin/commands/VerifySourceArtifactCurationsCommand.kt @@ -76,7 +76,7 @@ internal class VerifySourceArtifactCurationsCommand : CliktCommand( println(message) false } finally { - tempDir.safeDeleteRecursively(force = true) + tempDir.safeDeleteRecursively() } } != false } diff --git a/model/src/main/kotlin/utils/FileArchiver.kt b/model/src/main/kotlin/utils/FileArchiver.kt index f856ba6a73210..980022e4e07ed 100644 --- a/model/src/main/kotlin/utils/FileArchiver.kt +++ b/model/src/main/kotlin/utils/FileArchiver.kt @@ -95,7 +95,7 @@ class FileArchiver( logger.info { "Wrote archive of directory '$directory' to storage in $writeDuration." } - zipFile.parentFile.safeDeleteRecursively(force = true) + zipFile.parentFile.safeDeleteRecursively() } /** diff --git a/plugins/commands/upload-result-to-sw360/src/main/kotlin/UploadResultToSw360Command.kt b/plugins/commands/upload-result-to-sw360/src/main/kotlin/UploadResultToSw360Command.kt index d5265b3a47e65..84dc6b77b1be7 100644 --- a/plugins/commands/upload-result-to-sw360/src/main/kotlin/UploadResultToSw360Command.kt +++ b/plugins/commands/upload-result-to-sw360/src/main/kotlin/UploadResultToSw360Command.kt @@ -122,7 +122,7 @@ class UploadResultToSw360Command : OrtCommand( logger.error { "Could not upload source attachment: " + uploadResult.failedUploads() } } } finally { - tempDirectory.safeDeleteRecursively(force = true) + tempDirectory.safeDeleteRecursively() } } diff --git a/plugins/package-managers/conan/src/main/kotlin/Conan.kt b/plugins/package-managers/conan/src/main/kotlin/Conan.kt index 62355a388a69d..9782a6b81df98 100644 --- a/plugins/package-managers/conan/src/main/kotlin/Conan.kt +++ b/plugins/package-managers/conan/src/main/kotlin/Conan.kt @@ -177,7 +177,7 @@ class Conan( } val pkgInfos = parsePackageInfos(jsonFile) - jsonFile.parentFile.safeDeleteRecursively(force = true) + jsonFile.parentFile.safeDeleteRecursively() val packageList = removeProjectPackage(pkgInfos, definitionFile.name) val packages = parsePackages(packageList, workingDir) @@ -334,7 +334,7 @@ class Conan( val jsonFile = createOrtTempDir().resolve("inspect.json") run(workingDir, "inspect", pkgName, "--json", jsonFile.absolutePath) Json.parseToJsonElement(jsonFile.readText()).jsonObject.also { - jsonFile.parentFile.safeDeleteRecursively(force = true) + jsonFile.parentFile.safeDeleteRecursively() } } diff --git a/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt b/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt index 194c62f280e15..5cb8753b2124e 100644 --- a/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt +++ b/plugins/package-managers/gradle/src/main/kotlin/Gradle.kt @@ -247,7 +247,7 @@ class Gradle( } } - initScriptFile.parentFile.safeDeleteRecursively(force = true) + initScriptFile.parentFile.safeDeleteRecursively() val repositories = dependencyTreeModel.repositories.map { // TODO: Also handle authentication and snapshot policy. diff --git a/plugins/package-managers/maven/src/funTest/kotlin/MavenFunTest.kt b/plugins/package-managers/maven/src/funTest/kotlin/MavenFunTest.kt index 4d547a201cda9..309b698885ae9 100644 --- a/plugins/package-managers/maven/src/funTest/kotlin/MavenFunTest.kt +++ b/plugins/package-managers/maven/src/funTest/kotlin/MavenFunTest.kt @@ -89,7 +89,7 @@ class MavenFunTest : StringSpec({ // Delete the parent POM from the local repository to make sure it has to be resolved from Maven central. Os.userHomeDirectory .resolve(".m2/repository/org/springframework/boot/spring-boot-starter-parent/1.5.3.RELEASE") - .safeDeleteRecursively(force = true) + .safeDeleteRecursively() val definitionFile = getAssetFile("projects/synthetic/maven-parent/pom.xml") val expectedResultFile = getAssetFile("projects/synthetic/maven-parent-expected-output-root.yml") diff --git a/plugins/package-managers/nuget/src/main/kotlin/utils/NuGetInspector.kt b/plugins/package-managers/nuget/src/main/kotlin/utils/NuGetInspector.kt index 7f707096f2721..a12b182676417 100644 --- a/plugins/package-managers/nuget/src/main/kotlin/utils/NuGetInspector.kt +++ b/plugins/package-managers/nuget/src/main/kotlin/utils/NuGetInspector.kt @@ -68,8 +68,8 @@ internal object NuGetInspector : CommandLineTool { run(workingDir, *commandLineOptions.toTypedArray()) outputFile.inputStream().use { json.decodeFromStream(it) } } finally { - workingDir.resolve(".cache").safeDeleteRecursively(force = true) - outputFile.parentFile.safeDeleteRecursively(force = true) + workingDir.resolve(".cache").safeDeleteRecursively() + outputFile.parentFile.safeDeleteRecursively() } } diff --git a/plugins/package-managers/python/src/funTest/kotlin/utils/PythonInspectorFunTest.kt b/plugins/package-managers/python/src/funTest/kotlin/utils/PythonInspectorFunTest.kt index dc97674caecc7..947c7ea88ee28 100644 --- a/plugins/package-managers/python/src/funTest/kotlin/utils/PythonInspectorFunTest.kt +++ b/plugins/package-managers/python/src/funTest/kotlin/utils/PythonInspectorFunTest.kt @@ -42,7 +42,7 @@ class PythonInspectorFunTest : StringSpec({ analyzeSetupPyInsecurely = true ) } finally { - workingDir.resolve(".cache").safeDeleteRecursively(force = true) + workingDir.resolve(".cache").safeDeleteRecursively() } result.projects should haveSize(2) @@ -63,7 +63,7 @@ class PythonInspectorFunTest : StringSpec({ analyzeSetupPyInsecurely = false ) } finally { - workingDir.resolve(".cache").safeDeleteRecursively(force = true) + workingDir.resolve(".cache").safeDeleteRecursively() } result.projects should haveSize(1) diff --git a/plugins/package-managers/python/src/main/kotlin/Pip.kt b/plugins/package-managers/python/src/main/kotlin/Pip.kt index 431b8c99399e6..f6f931f047b4c 100644 --- a/plugins/package-managers/python/src/main/kotlin/Pip.kt +++ b/plugins/package-managers/python/src/main/kotlin/Pip.kt @@ -132,7 +132,7 @@ class Pip( analyzeSetupPyInsecurely = analyzeSetupPyInsecurely ) } finally { - workingDir.resolve(".cache").safeDeleteRecursively(force = true) + workingDir.resolve(".cache").safeDeleteRecursively() } }.onFailure { e -> e.showStackTrace() diff --git a/plugins/package-managers/python/src/main/kotlin/Poetry.kt b/plugins/package-managers/python/src/main/kotlin/Poetry.kt index c4b382cfed820..540292ce1c81c 100644 --- a/plugins/package-managers/python/src/main/kotlin/Poetry.kt +++ b/plugins/package-managers/python/src/main/kotlin/Poetry.kt @@ -126,7 +126,7 @@ class Poetry( return Pip(managerName, analysisRoot, analyzerConfig, repoConfig).runPythonInspector(requirementsFile) { detectPythonVersion(workingDir) }.also { - requirementsFile.parentFile.safeDeleteRecursively(force = true) + requirementsFile.parentFile.safeDeleteRecursively() } } diff --git a/plugins/package-managers/python/src/main/kotlin/utils/PythonInspector.kt b/plugins/package-managers/python/src/main/kotlin/utils/PythonInspector.kt index 10a0524b21183..69dde6884f94d 100644 --- a/plugins/package-managers/python/src/main/kotlin/utils/PythonInspector.kt +++ b/plugins/package-managers/python/src/main/kotlin/utils/PythonInspector.kt @@ -93,7 +93,7 @@ internal object PythonInspector : CommandLineTool { run(workingDir, *commandLineOptions.toTypedArray()) outputFile.inputStream().use { json.decodeFromStream(it) } } finally { - outputFile.parentFile.safeDeleteRecursively(force = true) + outputFile.parentFile.safeDeleteRecursively() } } diff --git a/plugins/package-managers/sbt/src/main/kotlin/Sbt.kt b/plugins/package-managers/sbt/src/main/kotlin/Sbt.kt index 263b5c053fdce..76a075bd86baf 100644 --- a/plugins/package-managers/sbt/src/main/kotlin/Sbt.kt +++ b/plugins/package-managers/sbt/src/main/kotlin/Sbt.kt @@ -75,7 +75,7 @@ class Sbt( resolve("project").mkdir() } - return super.getVersion(dummyProjectDir).also { dummyProjectDir.safeDeleteRecursively(force = true) } + return super.getVersion(dummyProjectDir).also { dummyProjectDir.safeDeleteRecursively() } } override fun getVersionArguments() = "${SBT_OPTIONS.joinToString(" ")} sbtVersion" diff --git a/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt b/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt index f7151fa377cb8..0b6228a154bb2 100644 --- a/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt +++ b/plugins/package-managers/spdx/src/main/kotlin/utils/SpdxResolvedDocument.kt @@ -385,7 +385,7 @@ private fun SpdxExternalDocumentReference.resolveFromDownload( ResolutionResult(document, uri, verifyChecksum(file, baseUri, managerName)) } finally { - tempDir.safeDeleteRecursively(force = true) + tempDir.safeDeleteRecursively() } } diff --git a/plugins/scanners/boyterlc/src/main/kotlin/BoyterLc.kt b/plugins/scanners/boyterlc/src/main/kotlin/BoyterLc.kt index 8e2fe1cbc8036..176785ae20894 100644 --- a/plugins/scanners/boyterlc/src/main/kotlin/BoyterLc.kt +++ b/plugins/scanners/boyterlc/src/main/kotlin/BoyterLc.kt @@ -87,7 +87,7 @@ class BoyterLc internal constructor(name: String, private val wrapperConfig: Sca if (stderr.isNotBlank()) logger.debug { stderr } if (isError) throw ScanException(errorMessage) - resultFile.readText().also { resultFile.parentFile.safeDeleteRecursively(force = true) } + resultFile.readText().also { resultFile.parentFile.safeDeleteRecursively() } } } diff --git a/plugins/scanners/dos/src/main/kotlin/DosScanner.kt b/plugins/scanners/dos/src/main/kotlin/DosScanner.kt index 866d29ba5cf0a..bcdd55c1114d7 100644 --- a/plugins/scanners/dos/src/main/kotlin/DosScanner.kt +++ b/plugins/scanners/dos/src/main/kotlin/DosScanner.kt @@ -175,7 +175,7 @@ class DosScanner internal constructor( val zipFile = tmpDir.resolve(zipName) sourceDir.packZip(zipFile) - sourceDir.safeDeleteRecursively(force = true) + sourceDir.safeDeleteRecursively() val uploadUrl = client.getUploadUrl(zipName) if (uploadUrl == null) { diff --git a/plugins/scanners/scancode/src/main/kotlin/ScanCode.kt b/plugins/scanners/scancode/src/main/kotlin/ScanCode.kt index 4dba0345d6ff8..ce932ed0fd22c 100644 --- a/plugins/scanners/scancode/src/main/kotlin/ScanCode.kt +++ b/plugins/scanners/scancode/src/main/kotlin/ScanCode.kt @@ -152,7 +152,7 @@ class ScanCode internal constructor( // Do not throw yet if the process exited with an error as some errors might turn out to be tolerable during // parsing. - resultFile.readText().also { resultFile.parentFile.safeDeleteRecursively(force = true) } + resultFile.readText().also { resultFile.parentFile.safeDeleteRecursively() } } } diff --git a/scanner/src/main/kotlin/Scanner.kt b/scanner/src/main/kotlin/Scanner.kt index d5a1b979d7fd1..5fe049208c323 100644 --- a/scanner/src/main/kotlin/Scanner.kt +++ b/scanner/src/main/kotlin/Scanner.kt @@ -609,7 +609,7 @@ class Scanner( ScanResult(provenance, scanner.details, summaryWithMappedLicenses) } } finally { - downloadDir.safeDeleteRecursively(force = true) + downloadDir.safeDeleteRecursively() } } @@ -718,7 +718,7 @@ class Scanner( ) ) } finally { - dir?.safeDeleteRecursively(force = true) + dir?.safeDeleteRecursively() } } } diff --git a/scanner/src/main/kotlin/provenance/ProvenanceDownloader.kt b/scanner/src/main/kotlin/provenance/ProvenanceDownloader.kt index ba35f11a18366..997ea4fc42394 100644 --- a/scanner/src/main/kotlin/provenance/ProvenanceDownloader.kt +++ b/scanner/src/main/kotlin/provenance/ProvenanceDownloader.kt @@ -108,7 +108,7 @@ class DefaultProvenanceDownloader( // Make sure that all nested repositories are removed. Even though we do not clone recursively above, nested // repositories could exist if the same working tree was previously cloned recursively. workingTree.getNested().forEach { (path, _) -> - root.resolve(path).safeDeleteRecursively(force = true) + root.resolve(path).safeDeleteRecursively() } // We need to make a copy of the working tree, because it could be used by another coroutine after this diff --git a/scanner/src/main/kotlin/storages/Sw360Storage.kt b/scanner/src/main/kotlin/storages/Sw360Storage.kt index 94bd191d95763..10b3b1394d006 100644 --- a/scanner/src/main/kotlin/storages/Sw360Storage.kt +++ b/scanner/src/main/kotlin/storages/Sw360Storage.kt @@ -105,7 +105,7 @@ class Sw360Storage( throw ScanStorageException(message) } - tempScanResultFile.safeDeleteRecursively(force = true) + tempScanResultFile.safeDeleteRecursively() return result } @@ -136,7 +136,7 @@ class Sw360Storage( throw ScanStorageException(message) } - tempScanResultFile.safeDeleteRecursively(force = true) + tempScanResultFile.safeDeleteRecursively() return result } diff --git a/scanner/src/main/kotlin/utils/FileListResolver.kt b/scanner/src/main/kotlin/utils/FileListResolver.kt index c267207905ca9..d89791d0a5a51 100644 --- a/scanner/src/main/kotlin/utils/FileListResolver.kt +++ b/scanner/src/main/kotlin/utils/FileListResolver.kt @@ -50,7 +50,7 @@ internal class FileListResolver( try { storage.putFileList(provenance, it) } finally { - dir.safeDeleteRecursively(force = true) + dir.safeDeleteRecursively() } } } diff --git a/utils/common/src/funTest/kotlin/SafeDeleteRecursivelyFunTest.kt b/utils/common/src/funTest/kotlin/SafeDeleteRecursivelyFunTest.kt index 29ed871a145a0..4c3a6e14e223b 100644 --- a/utils/common/src/funTest/kotlin/SafeDeleteRecursivelyFunTest.kt +++ b/utils/common/src/funTest/kotlin/SafeDeleteRecursivelyFunTest.kt @@ -42,7 +42,7 @@ class SafeDeleteRecursivelyFunTest : WordSpec({ } shouldNotThrow { - dir.safeDeleteRecursively(force = true) + dir.safeDeleteRecursively() } dir.exists() shouldBe false @@ -61,7 +61,7 @@ class SafeDeleteRecursivelyFunTest : WordSpec({ Git().download(pkg, nodeDir) shouldNotThrow { - nodeDir.safeDeleteRecursively(force = true) + nodeDir.safeDeleteRecursively() } nodeDir.exists() shouldBe false @@ -73,7 +73,7 @@ class SafeDeleteRecursivelyFunTest : WordSpec({ val deleteDir = baseDir.resolve("c/delete").apply { safeMkdirs() } shouldNotThrow { - deleteDir.safeDeleteRecursively(force = true, baseDir) + deleteDir.safeDeleteRecursively(baseDir) } deleteDir.exists() shouldBe false diff --git a/utils/common/src/main/kotlin/ArchiveUtils.kt b/utils/common/src/main/kotlin/ArchiveUtils.kt index 198e8efa55a06..85e46210509a7 100644 --- a/utils/common/src/main/kotlin/ArchiveUtils.kt +++ b/utils/common/src/main/kotlin/ArchiveUtils.kt @@ -229,7 +229,7 @@ fun File.unpackDeb(targetDirectory: File, filter: (ArchiveEntry) -> Boolean = { file.unpack(subDirectory, filter = filter) } } finally { - tempDir.safeDeleteRecursively(force = true) + tempDir.safeDeleteRecursively() } } diff --git a/utils/common/src/main/kotlin/Extensions.kt b/utils/common/src/main/kotlin/Extensions.kt index 3964213701534..afd4e270719fe 100644 --- a/utils/common/src/main/kotlin/Extensions.kt +++ b/utils/common/src/main/kotlin/Extensions.kt @@ -117,12 +117,11 @@ fun File.isSymbolicLink(): Boolean = fun File.realFile(): File = toPath().toRealPath().toFile() /** - * Delete files recursively without following symbolic links (Unix) or junctions (Windows). If [force] is `true`, files - * which were not deleted in the first attempt are set to be writable and then tried to be deleted again. If - * [baseDirectory] is given, all empty parent directories along the path to [baseDirectory] are also deleted; - * [baseDirectory] itself is not deleted. Throws an [IOException] if a file could not be deleted. + * Delete a directory recursively without following symbolic links (Unix) or junctions (Windows). If a [baseDirectory] + * is provided, all empty parent directories along the path to [baseDirectory] are also deleted; [baseDirectory] itself + * is not deleted. Throws an [IOException] if a directory or file could not be deleted. */ -fun File.safeDeleteRecursively(force: Boolean = false, baseDirectory: File? = null) { +fun File.safeDeleteRecursively(baseDirectory: File? = null) { // Note that Kotlin's `File.deleteRecursively()` extension function does not work here to delete files with // unmappable characters in their names, so use the `Path.deleteRecursively()` extension function instead. toPath().deleteRecursively()