<commit_before>/*
 * Copyright (c) 2020 by <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASSAL.launch;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

import org.apache.commons.lang3.SystemUtils;

import VASSAL.tools.version.GitProperties;

public class StandardConfig implements Config {
  private final Path baseDir; 
  private final Path docDir;
  private final Path confDir;
  private final Path tmpDir;
  private final Path prefsDir;

  private final Path errorLogPath;
  private final Path javaBinPath;

  private final int instanceID;

  private final String version;
  private final String reportableVersion;

  public StandardConfig() throws IOException {
    baseDir = Path.of(System.getProperty("user.dir"));

    docDir = baseDir.resolve(
      SystemUtils.IS_OS_MAC_OSX ? "Contents/Resources/doc" : "doc"
    );

    // Set up the config dir and ensure it exists
    if (SystemUtils.IS_OS_MAC_OSX) {
      confDir = Path.of(System.getProperty("user.home"), "Library/Application Support/VASSAL");
    }
    else if (SystemUtils.IS_OS_WINDOWS) {
      confDir = Path.of(System.getenv("APPDATA"), "VASSAL");
    }
    else {
      confDir = Path.of(System.getProperty("user.home"), ".VASSAL");
    }

    Files.createDirectories(confDir);    

    prefsDir = confDir.resolve("prefs");
    errorLogPath = confDir.resolve("errorLog-" + getVersion());

    javaBinPath = Path.of(System.getProperty("java.home"), "bin", "java");

    // Set up the temp dir and ensure it exists
    tmpDir = Files.createTempDirectory("vassal_");
    tmpDir.toFile().deleteOnExit();

    // Set the instance id from the system properties.
    final String idstr = System.getProperty("VASSAL.id");
    if (idstr == null) {
      instanceID = 0;
    }
    else {
      int id;
      try {
        id = Integer.parseInt(idstr);
      }
      catch (NumberFormatException e) {
        id = -1;
      }

      instanceID = id;
    }

    // Set the version, reportable version
    final GitProperties gitProperties = new GitProperties();
    version = gitProperties.getVersion();
    reportableVersion = version.contains("-") ? version.substring(0, version.indexOf('-')) : version;
  }

  @Override
  public String getVersion() {
    return version;
  }

  @Override
  public String getReportableVersion() {
    return reportableVersion; 
  }<commit_msg>Set the verision before we try to use it. Derp.<commit_after>/*
 * Copyright (c) 2020 by <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASSAL.launch;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

import org.apache.commons.lang3.SystemUtils;

import VASSAL.tools.version.GitProperties;

public class StandardConfig implements Config {
  private final Path baseDir; 
  private final Path docDir;
  private final Path confDir;
  private final Path tmpDir;
  private final Path prefsDir;

  private final Path errorLogPath;
  private final Path javaBinPath;

  private final int instanceID;

  private final String version;
  private final String reportableVersion;

  public StandardConfig() throws IOException {
    // Set the instance id from the system properties.
    final String idstr = System.getProperty("VASSAL.id");
    if (idstr == null) {
      instanceID = 0;
    }
    else {
      int id;
      try {
        id = Integer.parseInt(idstr);
      }
      catch (NumberFormatException e) {
        id = -1;
      }

      instanceID = id;
    }

    // Set the version, reportable version
    final GitProperties gitProperties = new GitProperties();
    version = gitProperties.getVersion();
    reportableVersion = version.contains("-") ? version.substring(0, version.indexOf('-')) : version;

    baseDir = Path.of(System.getProperty("user.dir"));

    docDir = baseDir.resolve(
      SystemUtils.IS_OS_MAC_OSX ? "Contents/Resources/doc" : "doc"
    );

    // Set up the config dir and ensure it exists
    if (SystemUtils.IS_OS_MAC_OSX) {
      confDir = Path.of(System.getProperty("user.home"), "Library/Application Support/VASSAL");
    }
    else if (SystemUtils.IS_OS_WINDOWS) {
      confDir = Path.of(System.getenv("APPDATA"), "VASSAL");
    }
    else {
      confDir = Path.of(System.getProperty("user.home"), ".VASSAL");
    }

    Files.createDirectories(confDir);    

    prefsDir = confDir.resolve("prefs");
    errorLogPath = confDir.resolve("errorLog-" + getVersion());

    javaBinPath = Path.of(System.getProperty("java.home"), "bin", "java");

    // Set up the temp dir and ensure it exists
    tmpDir = Files.createTempDirectory("vassal_");
    tmpDir.toFile().deleteOnExit();
  }

  @Override
  public String getVersion() {
    return version;
  }

  @Override
  public String getReportableVersion() {
    return reportableVersion; 
  }
{'fraction_non_alphanumeric': 0.1004352192835621, 'fraction_numerical': 0.002678272514228323, 'mean_word_length': 3.310966810966811, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5626594', 'n_tokens_mistral': 1731, 'n_tokens_neox': 1695, 'n_words': 555}