Native: Use NIO Files.createTemp*() in favor of File.createTemp*() extension functions
This commit is contained in:
+2
-1
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.konan.properties.resolvablePropertyString
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.util.DependencyDirectories
|
||||
import java.nio.file.Files
|
||||
import java.util.*
|
||||
|
||||
private val Project.jvmArgs
|
||||
@@ -127,7 +128,7 @@ internal class KotlinNativeCompilerRunner(project: Project) : KotlinNativeToolRu
|
||||
override fun transformArgs(args: List<String>): List<String> {
|
||||
if (!useArgFile) return super.transformArgs(args)
|
||||
|
||||
val argFile = createTempFile(prefix = "kotlinc-native-args", suffix = ".lst").apply { deleteOnExit() }
|
||||
val argFile = Files.createTempFile(/* prefix = */ "kotlinc-native-args", /* suffix = */ ".lst").toFile().apply { deleteOnExit() }
|
||||
argFile.printWriter().use { w ->
|
||||
args.forEach { arg ->
|
||||
val escapedArg = arg
|
||||
|
||||
+11
-12
@@ -105,11 +105,10 @@ internal data class CommonizerTaskParams(
|
||||
val parentDir = destinationDir.parentFile
|
||||
parentDir.mkdirs()
|
||||
|
||||
val destinationTmpDir = createTempDir(
|
||||
prefix = "tmp-" + destinationDir.name,
|
||||
suffix = ".new",
|
||||
directory = parentDir
|
||||
)
|
||||
val destinationTmpDir = Files.createTempDirectory(
|
||||
/* dir = */ parentDir.toPath(),
|
||||
/* prefix = */ "tmp-new-" + destinationDir.name
|
||||
).toFile()
|
||||
|
||||
commandLineArguments += "native-dist-commonize"
|
||||
commandLineArguments += "-distribution-path"
|
||||
@@ -256,16 +255,16 @@ private fun renameToTempAndDelete(directory: File) {
|
||||
directory
|
||||
} else {
|
||||
// first, rename the directory to some temp directory
|
||||
val tempDir = createTempFile(
|
||||
prefix = "tmp-" + directory.name,
|
||||
suffix = ".old",
|
||||
directory = directory.parentFile
|
||||
val tempDir = Files.createTempFile(
|
||||
/* dir = */ directory.parentFile.toPath(),
|
||||
/* prefix = */ "tmp-old-" + directory.name,
|
||||
/* suffix = */ null
|
||||
)
|
||||
tempDir.delete()
|
||||
Files.delete(tempDir)
|
||||
|
||||
Files.move(directory.toPath(), tempDir.toPath(), StandardCopyOption.ATOMIC_MOVE)
|
||||
Files.move(directory.toPath(), tempDir, StandardCopyOption.ATOMIC_MOVE)
|
||||
|
||||
tempDir
|
||||
tempDir.toFile()
|
||||
}
|
||||
|
||||
dirToRemove.deleteRecursively()
|
||||
|
||||
Reference in New Issue
Block a user