<commit_before>// Copied from a snapshot of Slipstream Mod Manager after 1.4.
// https://github.com/Vhati/Slipstream-Mod-Manager/blob/b980f4cdf64667799c013b8fd9025bcb0d389717/src/main/java/net/vhati/modmanager/core/FTLUtilities.java

package net.vhati.modmanager.core;

import java.awt.Component;
import java.io.File;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;


public class FTLUtilities {

	/**
	 * Confirms the FTL resources dir exists and contains the dat files.
	 */
	public static boolean isDatsDirValid( File d ) {
		if ( !d.exists() || !d.isDirectory() ) return false;
		if ( !new File(d, "data.dat").exists() ) return false;
		if ( !new File(d, "resource.dat").exists() ) return false;
		return true;
	}

	/**
	 * Returns the FTL resources dir, or null.
	 */
	public static File findDatsDir() {
		String steamPath = "Steam/steamapps/common/FTL Faster Than Light/resources";
		String gogPath = "GOG.com/Faster Than Light/resources";
		String humblePath = "FTL/resources";

		String xdgDataHome = System.getenv("XDG_DATA_HOME");
		if (xdgDataHome == null)
			xdgDataHome = System.getProperty("user.home") +"/.local/share";

		File[] candidates = new File[] {
			// Windows - Steam
			new File( new File(""+System.getenv("ProgramFiles(x86)")), steamPath ),
			new File( new File(""+System.getenv("ProgramFiles")), steamPath ),
			// Windows - GOG
			new File( new File(""+System.getenv("ProgramFiles(x86)")), gogPath ),
			new File( new File(""+System.getenv("ProgramFiles")), gogPath ),
			// Windows - Humble Bundle
			new File( new File(""+System.getenv("ProgramFiles(x86)")), humblePath ),
			new File( new File(""+System.getenv("ProgramFiles")), humblePath ),
			// Linux - Steam
			new File( xdgDataHome +"/.steam/steam/SteamApps/common/FTL Faster Than Light/data/resources" ),
			new File( xdgDataHome +"/.steam/steam/steamapps/common/FTL Faster Than Light/data/resources" ),
			// OSX - Steam
			new File( System.getProperty("user.home") +"/Library/Application Support/Steam/SteamApps/common/FTL Faster Than Light/FTL.app/Contents/Resources" ),
			// OSX
			new File( "/Applications/FTL.app/Contents/Resources" )
		};

		File result = null;<commit_msg>Fix to support an env var quirk in Ubuntu Linux<commit_after>// Copied from a snapshot of Slipstream Mod Manager after 1.4.
// https://github.com/Vhati/Slipstream-Mod-Manager/blob/b980f4cdf64667799c013b8fd9025bcb0d389717/src/main/java/net/vhati/modmanager/core/FTLUtilities.java

package net.vhati.modmanager.core;

import java.awt.Component;
import java.io.File;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileFilter;


public class FTLUtilities {

	/**
	 * Confirms the FTL resources dir exists and contains the dat files.
	 */
	public static boolean isDatsDirValid( File d ) {
		if ( !d.exists() || !d.isDirectory() ) return false;
		if ( !new File(d, "data.dat").exists() ) return false;
		if ( !new File(d, "resource.dat").exists() ) return false;
		return true;
	}

	/**
	 * Returns the FTL resources dir, or null.
	 */
	public static File findDatsDir() {
		String steamPath = "Steam/steamapps/common/FTL Faster Than Light/resources";
		String gogPath = "GOG.com/Faster Than Light/resources";
		String humblePath = "FTL/resources";

		String xdgDataHome = System.getenv("XDG_DATA_HOME");
		if (xdgDataHome == null) {
			xdgDataHome = System.getProperty("user.home") +"/.local/share";
		}
		String xdgDataHomeUbuntu = System.getenv("HOME");
		if (xdgDataHomeUbuntu == null) {
			xdgDataHomeUbuntu = System.getProperty("user.home") +"/.local/share";
		}

		File[] candidates = new File[] {
			// Windows - Steam
			new File( new File(""+System.getenv("ProgramFiles(x86)")), steamPath ),
			new File( new File(""+System.getenv("ProgramFiles")), steamPath ),
			// Windows - GOG
			new File( new File(""+System.getenv("ProgramFiles(x86)")), gogPath ),
			new File( new File(""+System.getenv("ProgramFiles")), gogPath ),
			// Windows - Humble Bundle
			new File( new File(""+System.getenv("ProgramFiles(x86)")), humblePath ),
			new File( new File(""+System.getenv("ProgramFiles")), humblePath ),
			// Linux - Steam
			new File( xdgDataHome +"/Steam/SteamApps/common/FTL Faster Than Light/data/resources" ),
			new File( xdgDataHome +"/.steam/steam/SteamApps/common/FTL Faster Than Light/data/resources" ),
			new File( xdgDataHome +"/.steam/steam/steamapps/common/FTL Faster Than Light/data/resources" ),
			// Linux Ubuntu - Steam
			new File( xdgDataHomeUbuntu +"/Steam/SteamApps/common/FTL Faster Than Light/data/resources" ),
			new File( xdgDataHomeUbuntu +"/.steam/steam/SteamApps/common/FTL Faster Than Light/data/resources" ),
			new File( xdgDataHomeUbuntu +"/.steam/steam/steamapps/common/FTL Faster Than Light/data/resources" ),
			// OSX - Steam
			new File( System.getProperty("user.home") +"/Library/Application Support/Steam/SteamApps/common/FTL Faster Than Light/FTL.app/Contents/Resources" ),
			// OSX
			new File( "/Applications/FTL.app/Contents/Resources" )
		};

		File result = null;
{'fraction_non_alphanumeric': 0.1464362012041173, 'fraction_numerical': 0.01359487279083317, 'mean_word_length': 4.109126984126984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '5448676', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1736, 'n_words': 394}