<commit_before>
#include <v8.h>
#include <fstream>
#include <string>
#include <streambuf>

using namespace v8;

int main(int argc, char* argv[]) {

  // Create a stack-allocated handle scope.
  HandleScope handle_scope;

  // Create a new context.
  Persistent<Context> context = Context::New();
  
  // Enter the created context for compiling and
  // running the hello world script. 
  Context::Scope context_scope(context);

  std::ifstream t("example.js");
  std::string str;

  t.seekg(0, std::ios::end);   
  str.reserve(t.tellg());<commit_msg>Take in requested file as argument. Check if file is open before running script.<commit_after>
#include <v8.h>
#include <fstream>
#include <string>
#include <streambuf>

using namespace v8;

int main(int argc, char* argv[]) {
  // Create a stack-allocated handle scope.
  HandleScope handle_scope;

  // Create a new context.
  Persistent<Context> context = Context::New();
  
  // Enter the created context for compiling and
  // running the hello world script. 
  Context::Scope context_scope(context);

  if (argc < 2) {
    fprintf(stderr, "ERROR: no file requested\n");
    return  EXIT_FAILURE;
  }

  std::ifstream t(argv[1]);

  if (!t.is_open()) {
    fprintf(stderr, "ERROR: (404) file not found\n");
    return  EXIT_FAILURE;
  }

  std::string str;

  t.seekg(0, std::ios::end);   
  str.reserve(t.tellg());
{'fraction_non_alphanumeric': 0.13732651570489407, 'fraction_numerical': 0.008035062089116142, 'mean_word_length': 3.7404844290657437, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 13, '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': '4176172', 'n_tokens_mistral': 467, 'n_tokens_neox': 452, 'n_words': 136}