<commit_before>using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using PatchKit.Unity.Patcher.Data;
using UnityEngine;
using Debug = UnityEngine.Debug;

namespace PatchKit.Unity.Patcher
{
    internal class PatcherAppStarter
    {
        private readonly string _path;

        public PatcherAppStarter(string path)
        {
            _path = path;
        }

        private void StartOSXApplication()
        {
            var directoryInfo = new DirectoryInfo(_path);

            var executableApp = directoryInfo.GetDirectories("*.app", SearchOption.TopDirectoryOnly).FirstOrDefault();

            if (executableApp == null)
            {
                throw new InvalidOperationException(string.Format("Couldn't find executable bundle for Mac OSX in {0}",
                    _path));
            }

            foreach (var file in executableApp.GetFiles("*", SearchOption.AllDirectories))
            {
                Chmod(file.FullName, "+x");
            }

            var processStartInfo = new ProcessStartInfo
            {
                FileName = "open",
                Arguments = string.Format("\"{0}\"", executableApp.FullName),
                WorkingDirectory = _path
            };

            Process.Start(processStartInfo);
        }

        private void StartLinuxApplication()
        {
            var directoryInfo = new DirectoryInfo(_path);

            var executableFile = directoryInfo.GetFiles("*", SearchOption.TopDirectoryOnly).Where(info =>
            {
                // Read magic bytes
                using (FileStream executableFileStream = File.OpenRead(info.FullName))
                {
                    using (BinaryReader executableBinaryReader = new BinaryReader(executableFileStream))
                    {
                        byte[] magicBytes = executableBinaryReader.ReadBytes(4);

                        if (magicBytes.Length == 4)<commit_msg>Secure Mac chmod to run only on executables<commit_after>using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using PatchKit.Unity.Patcher.Data;
using UnityEngine;
using Debug = UnityEngine.Debug;

namespace PatchKit.Unity.Patcher
{
    internal class PatcherAppStarter
    {
        private readonly string _path;

        public PatcherAppStarter(string path)
        {
            _path = path;
        }

        private void StartOSXApplication()
        {
            var directoryInfo = new DirectoryInfo(_path);

            var executableApp = directoryInfo.GetDirectories("*.app", SearchOption.TopDirectoryOnly).FirstOrDefault();

            if (executableApp == null)
            {
                throw new InvalidOperationException(string.Format("Couldn't find executable bundle for Mac OSX in {0}",
                    _path));
            }

            foreach (var file in executableApp.GetFiles("*", SearchOption.AllDirectories))
            {
                if (MagicBytes.IsMacExecutable(file.FullName))
                {
                    Chmod(file.FullName, "+x");
                }
            }

            var processStartInfo = new ProcessStartInfo
            {
                FileName = "open",
                Arguments = string.Format("\"{0}\"", executableApp.FullName),
                WorkingDirectory = _path
            };

            Process.Start(processStartInfo);
        }

        private void StartLinuxApplication()
        {
            var directoryInfo = new DirectoryInfo(_path);

            var executableFile = directoryInfo.GetFiles("*", SearchOption.TopDirectoryOnly).Where(info =>
            {
                // Read magic bytes
                using (FileStream executableFileStream = File.OpenRead(info.FullName))
                {
                    using (BinaryReader executableBinaryReader = new BinaryReader(executableFileStream))
                    {
                        byte[] magicBytes = executableBinaryReader.ReadBytes(4);

                        if (magicBytes.Length == 4)
{'fraction_non_alphanumeric': 0.084472049689441, 'fraction_numerical': 0.001987577639751553, 'mean_word_length': 1.799721835883171, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3210860', 'n_tokens_mistral': 1014, 'n_tokens_neox': 924, 'n_words': 216}