<commit_before>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Crevice.Config
{


    public class GlobalConfig
    {
        public readonly CLIOption.Result CLIOption;

        public readonly UI.MainForm MainForm;

        public GlobalConfig() : this(Config.CLIOption.ParseEnvironmentCommandLine())
        { }

        public GlobalConfig(CLIOption.Result cliOption)
        {
            CLIOption = cliOption;

            Directory.CreateDirectory(UserDirectory);
            
            MainForm = new UI.MainForm(this);
        }

        // %USERPROFILE%\\AppData\\Roaming\\Crevice4
        public string DefaultUserDirectory
            => Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                "Crevice4");

        // Parent directory of UserScriptFile.
        public string UserDirectory
            => Directory.GetParent(UserScriptFile).FullName;

        public string UserScriptFile
        {
            get
            {
                var scriptPath = CLIOption.ScriptFile;
                if (Path.IsPathRooted(scriptPath))
                {
                    return scriptPath;
                }
                var uri = new Uri(new Uri(DefaultUserDirectory + "\\"), scriptPath);
                return uri.LocalPath;
            }
        }

        public string UserScriptCacheFile
            => UserScriptFile + ".cache";

        public string ReadUserScriptFile()
        {
            if (!File.Exists(UserScriptFile))
            {
                return null;
            }
            return File.ReadAllText(UserScriptFile, Encoding.UTF8);
        }
        
        public string GetOrSetDefaultUserScriptFile(string defaultUserScriptString)
        {
            string userScriptString = ReadUserScriptFile();
            if (userScriptString == null)
            {
                WriteUserScriptFile(defaultUserScriptString);
                return defaultUserScriptString;
            }
            return userScriptString;
        }

        public void WriteUserScriptFile(string scriptFileString)
            => File.WriteAllText(UserScriptFile, scriptFileString, Encoding.UTF8);
    }
}
<commit_msg>Leaked commits.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Crevice.Config
{
    public class GlobalConfig
    {
        public readonly CLIOption.Result CLIOption;

        public readonly UI.MainForm MainForm;

        public GlobalConfig() : this(Config.CLIOption.ParseEnvironmentCommandLine())
        { }

        public GlobalConfig(CLIOption.Result cliOption)
        {
            CLIOption = cliOption;

            Directory.CreateDirectory(UserDirectory);
            
            MainForm = new UI.MainForm(this);
        }
        
        // %USERPROFILE%\\AppData\\Roaming\\Crevice4
        public string DefaultUserDirectory
            => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Crevice4");

        // Parent directory of UserScriptFile.
        public string UserDirectory
            => Directory.GetParent(UserScriptFile).FullName;

        public string UserScriptFile
        {
            get
            {
                var scriptPath = CLIOption.ScriptFile;
                if (Path.IsPathRooted(scriptPath))
                {
                    return scriptPath;
                }
                var uri = new Uri(new Uri(DefaultUserDirectory + "\\"), scriptPath);
                return uri.LocalPath;
            }
        }
        
        public string UserScriptCacheFile
            => UserScriptFile + ".cache";

        private string DisableIDESupportLoadDirectives(string userScriptString)
            => userScriptString.Replace("#load \"IDESupport", "//#load \"IDESupport");

        private string ReadUserScriptFile()
        {
            if (!File.Exists(UserScriptFile))
            {
                return null;
            }
            return File.ReadAllText(UserScriptFile, Encoding.UTF8);
        }
        
        public string GetOrSetDefaultUserScriptFile(string defaultUserScriptString, bool disableIDESupport = true)
        {
            string userScriptString = ReadUserScriptFile();
            if (userScriptString == null)
            {
                WriteUserScriptFile(defaultUserScriptString);
                userScriptString = defaultUserScriptString;
            }
            return disableIDESupport ? DisableIDESupportLoadDirectives(userScriptString) : userScriptString;
        }

        public void WriteUserScriptFile(string scriptFileString)
            => File.WriteAllText(UserScriptFile, scriptFileString, Encoding.UTF8);
    }
}

{'fraction_non_alphanumeric': 0.07677048204721286, 'fraction_numerical': 0.0015869867089863122, 'mean_word_length': 1.9313953488372093, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '1535458', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1220, 'n_words': 241}