<commit_before>/* This program is still a work in progress.
 * The purpose of this program is to be able to read and potentially
 * unpack the data from a .pak file and view its contents.
 *
 * In this context, a word is 4 bytes
 */
import java.io.*;
import java.nio.file.*;
import java.util.zip.*;

class Unpacker {
  /**
   * The file object that should be a .pak file.
   */
  private File file;

  /**
   * Constant buffer size for data
   */
  public final static int BUFSIZE = 1024 * 10; // 10 KB

  /**
   * Creates a Unpacker instance with the given
   * File object. The File object should not be null.
   * @param file  A file object
   */
  public Unpacker(File file) {
    this.file = file;
  }

  /**
   * Checks whether the File object in this instance is
   * actually a .pak file solely based on the extension
   * of the file.
   *
   * @return true if the file ends with .pak
   *         false otherwise
   */
  public boolean valid() {
    return file == null || file.getName().endsWith(".pak");
  }

  /**
   * Attempts to go through everything in the .pak file and
   * extract it into the given output directory.
   *
   * @param output The directory file that the files in the .pak
   *               archive will be extracted to.
   * @throws IOException
   *         When something goes wrong with accessing the .pak archive.
   */
  public void extract(File output)
    throws IOException, DataFormatException
  {
    RandomAccessFileLE ptr = new RandomAccessFileLE(file, "r");
    String header = "EyedentityGames Packing File 0.1";
    if(! ptr.readString(header.length()).equals(header)) {
      ptr.close();
      return;
    }

    /* 0x104 = 260 */
    ptr.seek(260);

    // read file count and start offset
    int count = ptr.readIntLE();
    long currOffset = ptr.readIntLE();
    int countLen = String.valueOf(count).length();

    // creating required data types here
    String outputText = "%0" + countLen + "d of %d: %s";
    String path;
    int zsize;
    int offset;
    Inflater inflater = new Inflater();
    int totalExtracted = 0;
    int size;
    int j = 1;

    // skips file if needed
    for(int i = 0; i < count; i++, j++) {
      // reading each file header
      ptr.seek(currOffset);<commit_msg>Disregard previous message; previous commit added ability to glob; realized I couldn't compile/run the constant stack size program.<commit_after>/* This program is still a work in progress.
 * The purpose of this program is to be able to read and potentially
 * unpack the data from a .pak file and view its contents.
 *
 * In this context, a word is 4 bytes
 */
import java.io.*;
import java.nio.file.*;
import java.util.zip.*;

class Unpacker {
  /**
   * The file object that should be a .pak file.
   */
  private File file;

  /**
   * Constant buffer size for data
   */
  public final static int BUFSIZE = 1024 * 10; // 10 KB

  /**
   * Creates a Unpacker instance with the given
   * File object. The File object should not be null.
   * @param file  A file object
   */
  public Unpacker(File file) {
    this.file = file;
  }

  /**
   * Checks whether the File object in this instance is
   * actually a .pak file solely based on the extension
   * of the file.
   *
   * @return true if the file ends with .pak
   *         false otherwise
   */
  public boolean valid() {
    return file == null || file.getName().endsWith(".pak");
  }

  /**
   * Attempts to go through everything in the .pak file and
   * extract it into the given output directory.
   *
   * @param output The directory file that the files in the .pak
   *               archive will be extracted to.
   * @throws IOException
   *         When something goes wrong with accessing the .pak archive.
   */
  public void extract(File output)
    throws IOException, DataFormatException
  {
    RandomAccessFileLE ptr = new RandomAccessFileLE(file, "r");
    String header = "EyedentityGames Packing File 0.1";
    if(! ptr.readString(header.length()).equals(header)) {
      ptr.close();
      return;
    }

    /* 0x104 = 260 */
    ptr.seek(260);

    // read file count and start offset
    int count = ptr.readIntLE();
    long currOffset = ptr.readIntLE();
    int countLen = String.valueOf(count).length();

    // creating required data types here
    String outputText = "%0" + countLen + "d of %d: %s";
    String path;
    int zsize;
    int offset;
    Inflater inflater = new Inflater();
    int size;
    int j = 1;

    // skips file if needed
    for(int i = 0; i < count; i++, j++) {
      // reading each file header
      ptr.seek(currOffset);
{'fraction_non_alphanumeric': 0.10117493472584857, 'fraction_numerical': 0.010661444734551785, 'mean_word_length': 2.451201201201201, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3270145', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1339, 'n_words': 553}