<commit_before>/*    ______________  ___  __  ___  _____  _____  ____  __  ____________  *\
**   / __/_  __/ __ \/ _ \/  |/  / / __/ |/ / _ \/ __ \/ / / /_  __/ __/  **
**  _\ \  / / / /_/ / , _/ /|_/ / / _//    / , _/ /_/ / /_/ / / / / _/    **
** /___/ /_/  \____/_/|_/_/  /_/ /___/_/|_/_/|_|\____/\____/ /_/ /___/    **
**                                                                        **
**                                            Storm Enroute (c) 2011      **
\*                                            www.storm-enroute.com       */

package org.brijest.storm



import java.io.File
import org.apache.commons.io.FileUtils
import org.brijest.bufferz._
import org.brijest.bufferz.shells._
import engine._
import engine.model.{World, Player}



object Initializer extends Logging {
  
  import Config._
  import impl._
  
  private def unpackNativeLibs() {
    val os = sys.props("os.name")
    val natstr = os match {
      case "Linux" => "linux-i586"
      case "Mac OS X" => "macosx-universal"
      case os => sys.error("Unknown OS: " + os)
    }
    val natext = os match {
      case "Linux" => "so"
      case "Mac OS X" => "jnilib"
      case os => sys.error("Unknown OS: " + os)
    }
    
    val candidates = for {
      jarfile <- new File("lib/").listFiles
      if jarfile.getName.endsWith(".jar") && jarfile.getName.contains(natstr)
    } {
      val archive = new java.util.zip.ZipFile(jarfile)
      val entries = archive.entries
      while (entries.hasMoreElements) {
        val entry = entries.nextElement()
        if (entry.getName.contains(natext)) {
          FileUtils.copyInputStreamToFile(archive.getInputStream(entry), new File("lib/" + entry.getName))
          System.loadLibrary(entry.getName)
          logger.info("unpacked native lib: " + entry.getName)
        }
      }
    }
  }
  
  def default() {
    // set java library path
    app.sys.props("java.library.path") = "lib/" + java.io.File.pathSeparator + app.sys.props("java.library.path")
    logger.info("java.library.path = " + app.sys.props("java.library.path"))
    
    // unpack gluegen-rt and jogl native libs
    unpackNativeLibs()
  }
  
  def apply(config: Config): Client = {
    // setup debug info
    config.logging match {
      case Some(logging.screen) =>
        import java.util.logging._
        LogManager.getLogManager.readConfiguration(javaLoggingScreen)
      case _ =>
    }
    <commit_msg>Fix the previously introduced bug with loading native libs.<commit_after>/*    ______________  ___  __  ___  _____  _____  ____  __  ____________  *\
**   / __/_  __/ __ \/ _ \/  |/  / / __/ |/ / _ \/ __ \/ / / /_  __/ __/  **
**  _\ \  / / / /_/ / , _/ /|_/ / / _//    / , _/ /_/ / /_/ / / / / _/    **
** /___/ /_/  \____/_/|_/_/  /_/ /___/_/|_/_/|_|\____/\____/ /_/ /___/    **
**                                                                        **
**                                            Storm Enroute (c) 2011      **
\*                                            www.storm-enroute.com       */

package org.brijest.storm



import java.io.File
import org.apache.commons.io.FileUtils
import org.brijest.bufferz._
import org.brijest.bufferz.shells._
import engine._
import engine.model.{World, Player}



object Initializer extends Logging {
  
  import Config._
  import impl._
  
  private def unpackNativeLibs() {
    val os = sys.props("os.name")
    val natstr = os match {
      case "Linux" => "linux-i586"
      case "Mac OS X" => "macosx-universal"
      case os => sys.error("Unknown OS: " + os)
    }
    val natext = os match {
      case "Linux" => "so"
      case "Mac OS X" => "jnilib"
      case os => sys.error("Unknown OS: " + os)
    }
    
    val candidates = for {
      jarfile <- new File("lib/").listFiles
      if jarfile.getName.endsWith(".jar") && jarfile.getName.contains(natstr)
    } {
      val archive = new java.util.zip.ZipFile(jarfile)
      val entries = archive.entries
      while (entries.hasMoreElements) {
        val entry = entries.nextElement()
        if (entry.getName.contains(natext)) {
          FileUtils.copyInputStreamToFile(archive.getInputStream(entry), new File("lib/" + entry.getName))
          logger.info("unpacked native lib: " + entry.getName)
        }
      }
    }
  }
  
  def default() {
    // set java library path
    app.sys.props("java.library.path") = "lib/" + java.io.File.pathSeparator + app.sys.props("java.library.path")
    logger.info("java.library.path = " + app.sys.props("java.library.path"))
    
    // unpack gluegen-rt and jogl native libs
    unpackNativeLibs()
  }
  
  def apply(config: Config): Client = {
    // setup debug info
    config.logging match {
      case Some(logging.screen) =>
        import java.util.logging._
        LogManager.getLogManager.readConfiguration(javaLoggingScreen)
      case _ =>
    }
    
{'fraction_non_alphanumeric': 0.14682866556836902, 'fraction_numerical': 0.002883031301482702, 'mean_word_length': 1.7240605720695457, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5319507', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1536, 'n_words': 277}