[klib] Finish refactoring ZipUtil after bootstrap advance
diff --git a/compiler/util-io/src/org/jetbrains/kotlin/konan/file/ZipUtil.kt b/compiler/util-io/src/org/jetbrains/kotlin/konan/file/ZipUtil.kt
index 3f781ef..f96641e 100644
--- a/compiler/util-io/src/org/jetbrains/kotlin/konan/file/ZipUtil.kt
+++ b/compiler/util-io/src/org/jetbrains/kotlin/konan/file/ZipUtil.kt
@@ -53,9 +53,9 @@
* Unpacks the contents of a zip archive located in [this] into the [destinationDirectory].
*
* @param destinationDirectory The directory to unpack the contents to.
+ * @param fromSubdirectory A subdirectory inside the archive to unpack. Specify "/" if you need to unpack the whole archive.
* @param resetTimeAttributes Whether to set the newly created files' time attributes
* (creation time, last access time, and last modification time) to zero.
- * @param fromSubdirectory A subdirectory inside the archive to unpack. Specify "/" if you need to unpack the whole archive.
*/
fun File.unzipTo(destinationDirectory: File, fromSubdirectory: File = File("/"), resetTimeAttributes: Boolean = false) {
withZipFileSystem {
@@ -67,9 +67,9 @@
* Unpacks the contents of a zip archive located in [this] into the [destinationDirectory].
*
* @param destinationDirectory The directory to unpack the contents to.
+ * @param fromSubdirectory A subdirectory inside the archive to unpack. Specify "/" if you need to unpack the whole archive.
* @param resetTimeAttributes Whether to set the newly created files' time attributes
* (creation time, last access time, and last modification time) to zero.
- * @param fromSubdirectory A subdirectory inside the archive to unpack. Specify "/" if you need to unpack the whole archive.
*/
fun Path.unzipTo(destinationDirectory: Path, fromSubdirectory: Path = Paths.get("/"), resetTimeAttributes: Boolean = false) {
File(this).unzipTo(File(destinationDirectory), File(fromSubdirectory), resetTimeAttributes)
@@ -81,8 +81,7 @@
fun <T> File.withZipFileSystem(action: (FileSystem) -> T): T = this.withZipFileSystem(false, action)
-// TODO: Make this function private after boostrap advance
-fun File.recursiveCopyTo(destination: File, resetTimeAttributes: Boolean = false) {
+private fun File.recursiveCopyTo(destination: File, resetTimeAttributes: Boolean = false) {
val sourcePath = javaPath
val destPath = destination.javaPath
val destFs = destPath.fileSystem
diff --git a/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinLibraryUtils.kt b/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinLibraryUtils.kt
index 7c45847..4b4c605 100644
--- a/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinLibraryUtils.kt
+++ b/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinLibraryUtils.kt
@@ -1,9 +1,7 @@
package org.jetbrains.kotlin.library
import org.jetbrains.kotlin.konan.file.File
-import org.jetbrains.kotlin.konan.file.file
-import org.jetbrains.kotlin.konan.file.recursiveCopyTo
-import org.jetbrains.kotlin.konan.file.withZipFileSystem
+import org.jetbrains.kotlin.konan.file.unzipTo
import org.jetbrains.kotlin.library.impl.zippedKotlinLibraryChecks
const val KLIB_FILE_EXTENSION = "klib"
@@ -24,10 +22,7 @@
newDir.delete()
}
- // TODO: Replace this with this.unzipTo(newDir) after bootstrap advance
- this.withZipFileSystem {
- it.file("/").recursiveCopyTo(newDir)
- }
+ this.unzipTo(newDir)
check(newDir.exists) { "Could not unpack $this as $newDir." }
}
diff --git a/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryLayoutImpl.kt b/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryLayoutImpl.kt
index f09ae73..9f67ec9 100644
--- a/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryLayoutImpl.kt
+++ b/compiler/util-klib/src/org/jetbrains/kotlin/library/impl/KotlinLibraryLayoutImpl.kt
@@ -3,7 +3,6 @@
import org.jetbrains.kotlin.konan.file.File
import org.jetbrains.kotlin.konan.file.file
import org.jetbrains.kotlin.konan.file.unzipTo
-import org.jetbrains.kotlin.konan.file.recursiveCopyTo
import org.jetbrains.kotlin.konan.file.withZipFileSystem
import org.jetbrains.kotlin.library.*
import org.jetbrains.kotlin.util.removeSuffixIfPresent
@@ -111,19 +110,11 @@
fun KotlinLibraryLayoutImpl.extractDir(directory: File): File = extractDir(this.klib, directory)
-// TODO: Use this implementation after bootstrap advance
-//private fun extractDir(zipFile: File, directory: File): File {
-// val temporary = org.jetbrains.kotlin.konan.file.createTempDir(directory.name)
-// temporary.deleteOnExitRecursively()
-// zipFile.unzipTo(temporary, fromSubdirectory = directory)
-// return temporary
-//}
-
-private fun extractDir(zipFile: File, directory: File): File = zipFile.withZipFileSystem { zipFileSystem ->
+private fun extractDir(zipFile: File, directory: File): File {
val temporary = org.jetbrains.kotlin.konan.file.createTempDir(directory.name)
- zipFileSystem.file(directory).recursiveCopyTo(temporary)
temporary.deleteOnExitRecursively()
- temporary
+ zipFile.unzipTo(temporary, fromSubdirectory = directory)
+ return temporary
}
open class ExtractingKotlinLibraryLayout(zipped: KotlinLibraryLayoutImpl) : KotlinLibraryLayout {