<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Inject;

namespace PathfinderPatcher
{
    // This will be the modloader.
    public static class PatcherProgram
    {
        internal static void Main(string[] args)
        {
            AssemblyDefinition ad = null;
            try
            {
                Console.WriteLine(String.Join("|", args));
                string pathfinderDir = "", exeDir = "";
                bool spitOutHacknetOnly = false;
                int index = 0;

                char separator = Path.DirectorySeparatorChar;
                // pathfinder arguments
                foreach (var arg in args)
                {
                    if (arg.Equals("-pathfinderDir")) // the Pathfinder.dll's directory
                        pathfinderDir = args[index + 1] + separator;
                    if (arg.Equals("-exeDir")) // the Hacknet.exe's directory
                        exeDir = args[index + 1] + separator;
                    if (arg.Equals("-spit")) // spit modifications without injected code
                        spitOutHacknetOnly = true;
                    index++;
                }

                // Loads Hacknet.exe's assembly
                ad = LoadAssembly(exeDir + "Hacknet.exe");

                // Loads FNA.dll for some extra injections
                var fna = LoadAssembly(exeDir + "FNA.dll");

                // Adds Pathfinder internal attribute hack
                ad.AddAssemblyAttribute<InternalsVisibleToAttribute>("Pathfinder");
                // Removes internal visibility from types
                ad.RemoveInternals();

                var mod = ad.MainModule;

                // Ensure the os field is internal
                var osField = ad.MainModule.GetType("Hacknet.Computer").GetField("os");
                osField.IsPrivate = false;
                osField.IsAssembly = true;

                // Ensure MissionListingServer's fields are internal
                var missionServer = ad.MainModule.GetType("Hacknet.MissionListingServer");
                foreach (var f in missionServer.Fields)
                {<commit_msg>Added Linux/Mac support of Pathfinder via PathfinderPatcher<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Inject;

namespace PathfinderPatcher
{
    // This will be the modloader.
    public static class PatcherProgram
    {
        internal static void Main(string[] args)
        {
            AssemblyDefinition ad = null;
            try
            {
                Console.WriteLine(String.Join("|", args));
                string pathfinderDir = "", exeDir = "";
                bool spitOutHacknetOnly = false;
                int index = 0;

                char separator = Path.DirectorySeparatorChar;
                // pathfinder arguments
                foreach (var arg in args)
                {
                    if (arg.Equals("-pathfinderDir")) // the Pathfinder.dll's directory
                        pathfinderDir = args[index + 1] + separator;
                    if (arg.Equals("-exeDir")) // the Hacknet.exe's directory
                        exeDir = args[index + 1] + separator;
                    if (arg.Equals("-spit")) // spit modifications without injected code
                        spitOutHacknetOnly = true;
                    index++;
                }

                if(File.Exists("Hacknet"))
                {
                    var txt = File.ReadAllText("Hacknet");
                    txt = txt.Replace("Hacknet", "HacknetPathfinder");
                    File.WriteAllText("HacknetPathfinder", txt);
                }

                foreach (var n in new string[]{ "Hacknet.bin.x86", "Hacknet.bin.x86_64", "Hacknet.bin.osx" })
                    if(File.Exists(n)) File.Copy(n, n.Replace("Hacknet", "HacknetPathfinder"), true);

                // Loads Hacknet.exe's assembly
                ad = LoadAssembly(exeDir + "Hacknet.exe");

                // Loads FNA.dll for some extra injections
                var fna = LoadAssembly(exeDir + "FNA.dll");

                // Adds Pathfinder internal attribute hack
                ad.AddAssemblyAttribute<InternalsVisibleToAttribute>("Pathfinder");
                // Removes internal visibility from types
                ad.RemoveInternals();

                var mod = ad.MainModule;

                // Ensure the os field is internal
                var osField = ad.MainModule.GetType("Hacknet.Computer").GetField("os");
                osField.IsPrivate = false;
                osField.IsAssembly = true;

                // Ensure MissionListingServer's fields are internal
                var missionServer = ad.MainModule.GetType("Hacknet.MissionListingServer");
                foreach (var f in missionServer.Fields)
                {
{'fraction_non_alphanumeric': 0.09282617264485613, 'fraction_numerical': 0.002364998029168309, 'mean_word_length': 1.5826972010178118, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4425133', 'n_tokens_mistral': 1356, 'n_tokens_neox': 1224, 'n_words': 313}