<commit_before>//-----------------------------------------------------------------------------
// HIMG, by <NAME>, 2015
//
// This is free and unencumbered software released into the public domain.
//
// See LICENSE for details.
//-----------------------------------------------------------------------------

#include <cstdint>
#include <fstream>
#include <iostream>

#include <FreeImage.h>

#include "decoder.h"

int main(int argc, const char **argv) {
  if (argc < 3) {
    std::cout << "Usage: " << argv[0] << " image outfile" << std::endl;
    return 0;
  }

  // Load the packed data from a file.
  std::vector<uint8_t> packed_data;
  {
    // Open file.
    std::ifstream f(argv[1], std::ifstream::in | std::ofstream::binary);
    if (f.bad()) {
      std::cout << "Unable to read file " << argv[1] << std::endl;
      return -1;
    }

    // Get file size.
    f.seekg(0, std::ifstream::end);
    int file_size = static_cast<int>(f.tellg());
    f.seekg(0, std::ifstream::beg);
    std::cout << "File size: " << file_size << std::endl;

    // Read the file data into our buffer.
    packed_data.resize(file_size);<commit_msg>Fix crash when dhimg is invoked with non-existent input file<commit_after>//-----------------------------------------------------------------------------
// HIMG, by <NAME>, 2015
//
// This is free and unencumbered software released into the public domain.
//
// See LICENSE for details.
//-----------------------------------------------------------------------------

#include <cstdint>
#include <fstream>
#include <iostream>

#include <FreeImage.h>

#include "decoder.h"

int main(int argc, const char **argv) {
  if (argc < 3) {
    std::cout << "Usage: " << argv[0] << " image outfile" << std::endl;
    return 0;
  }

  // Load the packed data from a file.
  std::vector<uint8_t> packed_data;
  {
    // Open file.
    std::ifstream f(argv[1], std::ifstream::in | std::ofstream::binary);
    if (!f.good()) {
      std::cout << "Unable to read file " << argv[1] << std::endl;
      return -1;
    }

    // Get file size.
    f.seekg(0, std::ifstream::end);
    int file_size = static_cast<int>(f.tellg());
    f.seekg(0, std::ifstream::beg);
    std::cout << "File size: " << file_size << std::endl;

    // Read the file data into our buffer.
    packed_data.resize(file_size);
{'fraction_non_alphanumeric': 0.28546787408365676, 'fraction_numerical': 0.01121172919361794, 'mean_word_length': 1.8677379480840544, 'pattern_counts': {'":': 0, '<': 59, '<?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': '2041305', 'n_tokens_mistral': 743, 'n_tokens_neox': 714, 'n_words': 200}