Don't use FileUtil in BuiltInsSerializer
See the comment
This commit is contained in:
@@ -19,7 +19,6 @@ package org.jetbrains.jet.utils.builtinsSerializer
|
||||
import java.io.File
|
||||
import java.io.PrintStream
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.jet.config.CompilerConfiguration
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
|
||||
import org.jetbrains.jet.descriptors.serialization.DescriptorSerializer
|
||||
@@ -39,12 +38,12 @@ import org.jetbrains.jet.config.CommonConfigurationKeys
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM
|
||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext
|
||||
import org.jetbrains.jet.di.InjectorForJavaDescriptorResolverUtil
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import org.jetbrains.jet.lang.types.lang.BuiltInsPackageMigration
|
||||
import org.jetbrains.jet.utils.recursePostOrder
|
||||
|
||||
public class BuiltInsSerializer(val out: PrintStream?) {
|
||||
private var totalSize = 0
|
||||
@@ -76,9 +75,10 @@ public class BuiltInsSerializer(val out: PrintStream?) {
|
||||
val session = AnalyzerFacadeForJVM.createLazyResolveSession(project, files, BindingTraceContext(), false)
|
||||
val module = session.getModuleDescriptor()
|
||||
|
||||
if (!FileUtil.delete(destDir)) {
|
||||
System.err.println("Could not delete: " + destDir)
|
||||
}
|
||||
// We don't use FileUtil because it spawns JNA initialization, which fails because we don't have (and don't want to have) its
|
||||
// native libraries in the compiler jar (libjnidispatch.so / jnidispatch.dll / ...)
|
||||
destDir.recursePostOrder { it.delete() }
|
||||
|
||||
if (!destDir.mkdirs()) {
|
||||
System.err.println("Could not make directories: " + destDir)
|
||||
}
|
||||
@@ -162,7 +162,9 @@ public class BuiltInsSerializer(val out: PrintStream?) {
|
||||
fun write(destDir: File, fileName: String, stream: ByteArrayOutputStream) {
|
||||
totalSize += stream.size()
|
||||
totalFiles++
|
||||
FileUtil.writeToFile(File(destDir, fileName), stream.toByteArray())
|
||||
val file = File(destDir, fileName)
|
||||
file.getParentFile()?.mkdirs()
|
||||
file.writeBytes(stream.toByteArray())
|
||||
}
|
||||
|
||||
fun getFileName(classDescriptor: ClassDescriptor): String {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.utils
|
||||
|
||||
import java.io.File
|
||||
|
||||
// Similar to kotlin.io.recurse, but processes each directory after its children
|
||||
public fun File.recursePostOrder(block: (File) -> Unit): Unit {
|
||||
val children = this.listFiles()
|
||||
if (children != null) {
|
||||
for (child in children) {
|
||||
child.recursePostOrder(block)
|
||||
}
|
||||
}
|
||||
block(this)
|
||||
}
|
||||
Reference in New Issue
Block a user