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.HostManager
|
||||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
import org.jetbrains.kotlin.konan.util.DependencyDirectories
|
import org.jetbrains.kotlin.konan.util.DependencyDirectories
|
||||||
|
import java.nio.file.Files
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
private val Project.jvmArgs
|
private val Project.jvmArgs
|
||||||
@@ -127,7 +128,7 @@ internal class KotlinNativeCompilerRunner(project: Project) : KotlinNativeToolRu
|
|||||||
override fun transformArgs(args: List<String>): List<String> {
|
override fun transformArgs(args: List<String>): List<String> {
|
||||||
if (!useArgFile) return super.transformArgs(args)
|
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 ->
|
argFile.printWriter().use { w ->
|
||||||
args.forEach { arg ->
|
args.forEach { arg ->
|
||||||
val escapedArg = arg
|
val escapedArg = arg
|
||||||
|
|||||||
+11
-12
@@ -105,11 +105,10 @@ internal data class CommonizerTaskParams(
|
|||||||
val parentDir = destinationDir.parentFile
|
val parentDir = destinationDir.parentFile
|
||||||
parentDir.mkdirs()
|
parentDir.mkdirs()
|
||||||
|
|
||||||
val destinationTmpDir = createTempDir(
|
val destinationTmpDir = Files.createTempDirectory(
|
||||||
prefix = "tmp-" + destinationDir.name,
|
/* dir = */ parentDir.toPath(),
|
||||||
suffix = ".new",
|
/* prefix = */ "tmp-new-" + destinationDir.name
|
||||||
directory = parentDir
|
).toFile()
|
||||||
)
|
|
||||||
|
|
||||||
commandLineArguments += "native-dist-commonize"
|
commandLineArguments += "native-dist-commonize"
|
||||||
commandLineArguments += "-distribution-path"
|
commandLineArguments += "-distribution-path"
|
||||||
@@ -256,16 +255,16 @@ private fun renameToTempAndDelete(directory: File) {
|
|||||||
directory
|
directory
|
||||||
} else {
|
} else {
|
||||||
// first, rename the directory to some temp directory
|
// first, rename the directory to some temp directory
|
||||||
val tempDir = createTempFile(
|
val tempDir = Files.createTempFile(
|
||||||
prefix = "tmp-" + directory.name,
|
/* dir = */ directory.parentFile.toPath(),
|
||||||
suffix = ".old",
|
/* prefix = */ "tmp-old-" + directory.name,
|
||||||
directory = directory.parentFile
|
/* 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()
|
dirToRemove.deleteRecursively()
|
||||||
|
|||||||
Reference in New Issue
Block a user