<commit_before>﻿using Microsoft.Win32;
using NLog;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace BSU.Sync
{
    public static class TeamSpeakPlugin
    {
        private static Logger logger = LogManager.GetCurrentClassLogger();
        /// <summary>
        /// Determines if TeamSpeak is installed 
        /// </summary>
        /// <returns></returns>
        public static bool TeamSpeakInstalled()
        {
            return TeamSpeakPath() != string.Empty;
        }
        /// <summary>
        /// Determines the location of TeamSpeak
        /// </summary>
        /// <returns></returns>
        public static string TeamSpeakPath()
        {
            RegistryKey localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
            localKey = localKey.OpenSubKey(@"SOFTWARE\TeamSpeak 3 Client");
            if (localKey != null)
            {
                return localKey.GetValue(null).ToString();
            }

            RegistryKey localkey32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
            localkey32 = localkey32.OpenSubKey(@"SOFTWARE\TeamSpeak 3 Client");
            if (localkey32 != null)
            {
                return localkey32.GetValue(null).ToString();
            }

            return string.Empty;
        }
        /// <summary>
        /// Gets a list of all mod folders which contain 
        /// </summary>
        /// <param name="Mods"></param>
        /// <param name="LocalPath"></param>
        /// <returns></returns>
        public static List<ModFolder> GetModFoldersWithPlugins(List<ModFolder> Mods, string LocalPath)
        {
            List<ModFolder> returnList = new List<ModFolder>();

            foreach (ModFolder m in Mods)
            {
                DirectoryInfo modPath = new DirectoryInfo(Path.Combine(LocalPath.ToString(), m.ModName.ToString()));
                DirectoryInfo[] folders = modPath.GetDirectories();
                if (folders.Any(x => x.FullName.Equals(Path.Combine(modPath.FullName, "plugins"))))
                {
                    DirectoryInfo modPluginFolder = new DirectoryInfo(Path.Combine(modPath.FullName, "plugins"));
                    DirectoryInfo tsPluginFolder = new DirectoryInfo(Path.Combine(TeamSpeakPlugin.TeamSpeakPath(), "plugins"));

                    logger.Trace("Plugins exists inside of {0}", modPath);
                    returnList.Add(m);
                }
            }

            return returnList;
        }
    }
}<commit_msg>Added support for different plugin folder names to TeamSpeakPlugin in BSU.Sync as well.<commit_after>﻿using Microsoft.Win32;
using NLog;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace BSU.Sync
{
    public static class TeamSpeakPlugin
    {
        private static Logger logger = LogManager.GetCurrentClassLogger();
        /// <summary>
        /// Determines if TeamSpeak is installed 
        /// </summary>
        /// <returns></returns>
        public static bool TeamSpeakInstalled()
        {
            return TeamSpeakPath() != string.Empty;
        }
        /// <summary>
        /// Determines the location of TeamSpeak
        /// </summary>
        /// <returns></returns>
        public static string TeamSpeakPath()
        {
            RegistryKey localKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
            localKey = localKey.OpenSubKey(@"SOFTWARE\TeamSpeak 3 Client");
            if (localKey != null)
            {
                return localKey.GetValue(null).ToString();
            }

            RegistryKey localkey32 = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
            localkey32 = localkey32.OpenSubKey(@"SOFTWARE\TeamSpeak 3 Client");
            if (localkey32 != null)
            {
                return localkey32.GetValue(null).ToString();
            }

            return string.Empty;
        }
        /// <summary>
        /// Gets a list of all mod folders which contain 
        /// </summary>
        /// <param name="Mods"></param>
        /// <param name="LocalPath"></param>
        /// <returns></returns>
        public static List<ModFolder> GetModFoldersWithPlugins(List<ModFolder> Mods, string LocalPath)
        {
            List<ModFolder> returnList = new List<ModFolder>();

            foreach (ModFolder m in Mods)
            {
                DirectoryInfo modPath = new DirectoryInfo(Path.Combine(LocalPath.ToString(), m.ModName.ToString()));
                DirectoryInfo[] folders = modPath.GetDirectories();
                List<string> pluginFolders = new List<string>();
                pluginFolders.Add("plugins");
                pluginFolders.Add("plugin");
                // ^ Support for both TFAR and ACRE 
                foreach (string folder in pluginFolders)
                {
                    if (folders.Any(x => x.FullName.Equals(Path.Combine(modPath.FullName, folder))))
                    {
                        DirectoryInfo modPluginFolder = new DirectoryInfo(Path.Combine(modPath.FullName, folder));
                        DirectoryInfo tsPluginFolder = new DirectoryInfo(Path.Combine(TeamSpeakPlugin.TeamSpeakPath(), folder));

                        logger.Trace("Plugins exists inside of {0}", modPath);
                        returnList.Add(m);
                    }
                }
            }

            return returnList;
        }
    }
}
{'fraction_non_alphanumeric': 0.10850333995306012, 'fraction_numerical': 0.006860444123487994, 'mean_word_length': 1.8497942386831276, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 47, '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': '7203668', 'n_tokens_mistral': 1479, 'n_tokens_neox': 1377, 'n_words': 307}