<commit_before>//
//  emulator_main.c
//  dcpu
//
//  Created by Artur on 30/09/2013.
//  Copyright (c) 2013 <NAME>. All rights reserved.
//

#include <cstdint>
#include <cstdlib>

#include <fstream>
#include <iostream>
#include <vector>

#include "Core.h"

using namespace std;

enum ReturnCodes {
    RETURN_SUCCESS = 0,
    RETURN_WRONG_INVOCATION = 1,
    RETURN_FILE_ERROR = 2,
    RETURN_CORE_EXCEPTION = 3,
};

static constexpr int BUF_SIZE = 1024;

void mainLoop(Core& core);
void printHelp();

int main(int argc, char** argv) {
    if(argc < 2) {
        printHelp();
        return RETURN_WRONG_INVOCATION;
    }
    
    ifstream inputFile{argv[1], ios_base::in | ios_base::binary};
    if(inputFile.bad()) {
        cout << "Could not open " << argv[1] << endl;
        return RETURN_FILE_ERROR;
    }

    vector<uint16_t> memory;
    uint16_t buffer[BUF_SIZE];
    
    while(inputFile) {
        memset(buffer, 0, BUF_SIZE * sizeof(uint16_t));
        auto size = inputFile.readsome(reinterpret_cast<char*>(buffer), BUF_SIZE * sizeof(uint16_t));
        memory.insert(memory.end(), buffer, buffer + (size / sizeof(uint16_t)));
    }
    
    Core core;
    core.setMemory(memory);
    mainLoop(core);
    <commit_msg>And it actually loads/quits<commit_after>//
//  emulator_main.c
//  dcpu
//
//  Created by Artur on 30/09/2013.
//  Copyright (c) 2013 <NAME>. All rights reserved.
//

#include <cstdint>
#include <cstdlib>

#include <fstream>
#include <iostream>
#include <vector>

#include "Core.h"

using namespace std;

enum ReturnCodes {
    RETURN_SUCCESS = 0,
    RETURN_WRONG_INVOCATION = 1,
    RETURN_FILE_ERROR = 2,
    RETURN_CORE_EXCEPTION = 3,
};

static constexpr int BUF_SIZE = 1024;

void mainLoop(Core& core);
void printHelp();

int main(int argc, char** argv) {
    if(argc < 2) {
        printHelp();
        return RETURN_WRONG_INVOCATION;
    }
    
    ifstream inputFile{argv[1], ios_base::in | ios_base::binary};
    if(inputFile.bad()) {
        cout << "Could not open " << argv[1] << endl;
        return RETURN_FILE_ERROR;
    }

    vector<uint16_t> memory;
    uint16_t buffer[BUF_SIZE];
    
    while(true) {
        memset(buffer, 0, BUF_SIZE * sizeof(uint16_t));
        auto size = inputFile.readsome(reinterpret_cast<char*>(buffer), BUF_SIZE * sizeof(uint16_t));
        if(size <= 0) {
            break;
        }
        memory.insert(memory.end(), buffer, buffer + (size / sizeof(uint16_t)));
    }
    
    Core core;
    core.setMemory(memory);
    mainLoop(core);
    
{'fraction_non_alphanumeric': 0.13539192399049882, 'fraction_numerical': 0.027315914489311165, 'mean_word_length': 2.881720430107527, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 19, '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': '4301936', 'n_tokens_mistral': 959, 'n_tokens_neox': 895, 'n_words': 198}