<commit_before>package org.telegram.tl.builder

import java.io.File
import java.util.ArrayList
import java.util.HashSet
import java.io.InputStreamReader
import java.io.BufferedReader

/**
 * Created with IntelliJ IDEA.
 * User: ex3ndr
 * Date: 02.11.13
 * Time: 6:37
 */

fun File.recursiveFind(filter: (file: File) -> Boolean): List<File> {
    var res = ArrayList<File>()
    var stack = ArrayList<File>()
    stack.add(this)
    while(stack.size() > 0) {
        var item = stack.remove(0);
        var files = item.listFiles()
        if (files != null)
        {
            for(f in files!!) {
                if (f.isDirectory()) {
                    stack.add(f);
                }

                if (filter.invoke(f)) {
                    res.add(f)
                }
            }
        }
    }
    return res;
}

fun exec(command: String, workingFolder: String)
{
    println(command);
    var process = Runtime.getRuntime().exec(command, null, File(workingFolder));
    var inStream = BufferedReader(InputStreamReader(process.getErrorStream()!!));
    var line = inStream.readLine()
    while (line != null) {
        System.out.println(line);
        line = inStream.readLine()
    }
    inStream.close();
}

fun compileClasses(srcFolder: String, workingFolder: String, destFolder: String) {
    var args = "-classpath " + File(".").getAbsoluteFile() + "/tl-core.jar -d " + destFolder + " ";

    var files = File(srcFolder).recursiveFind {(x) -> x.extension == "java" };

    for(f in files) {
        args += f.getAbsolutePath() + " ";
    }

    File(workingFolder + "/" + destFolder).mkdirs();
    exec("javac " + args, workingFolder);
}

fun buildJar(classesFolder: String, jarName: String, workingFolder: String) {
    var args = "";
    var files = File(workingFolder + "/" + classesFolder).recursiveFind {(x) -> x.extension == "class" };

    for(f in files) {
        args += f.getAbsolutePath().substring((workingFolder + "/" + classesFolder + "/").size) + " ";<commit_msg>Fixed erasing args names during compilation<commit_after>package org.telegram.tl.builder

import java.io.File
import java.util.ArrayList
import java.util.HashSet
import java.io.InputStreamReader
import java.io.BufferedReader

/**
 * Created with IntelliJ IDEA.
 * User: ex3ndr
 * Date: 02.11.13
 * Time: 6:37
 */

fun File.recursiveFind(filter: (file: File) -> Boolean): List<File> {
    var res = ArrayList<File>()
    var stack = ArrayList<File>()
    stack.add(this)
    while(stack.size() > 0) {
        var item = stack.remove(0);
        var files = item.listFiles()
        if (files != null)
        {
            for(f in files!!) {
                if (f.isDirectory()) {
                    stack.add(f);
                }

                if (filter.invoke(f)) {
                    res.add(f)
                }
            }
        }
    }
    return res;
}

fun exec(command: String, workingFolder: String)
{
    println(command);
    var process = Runtime.getRuntime().exec(command, null, File(workingFolder));
    var inStream = BufferedReader(InputStreamReader(process.getErrorStream()!!));
    var line = inStream.readLine()
    while (line != null) {
        System.out.println(line);
        line = inStream.readLine()
    }
    inStream.close();
}

fun compileClasses(srcFolder: String, workingFolder: String, destFolder: String) {
    var args = "-g:vars -classpath " + File(".").getAbsoluteFile() + "/tl-core.jar -d " + destFolder + " ";

    var files = File(srcFolder).recursiveFind {(x) -> x.extension == "java" };

    for(f in files) {
        args += f.getAbsolutePath() + " ";
    }

    File(workingFolder + "/" + destFolder).mkdirs();
    exec("javac " + args, workingFolder);
}

fun buildJar(classesFolder: String, jarName: String, workingFolder: String) {
    var args = "";
    var files = File(workingFolder + "/" + classesFolder).recursiveFind {(x) -> x.extension == "class" };

    for(f in files) {
        args += f.getAbsolutePath().substring((workingFolder + "/" + classesFolder + "/").size) + " ";
{'fraction_non_alphanumeric': 0.15239980207817913, 'fraction_numerical': 0.005937654626422563, 'mean_word_length': 2.4974048442906573, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5210765', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1226, 'n_words': 274}