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

namespace ShadowShifter
{
	public class Patcher
	{
		public static string MainFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

		public static string ErrorMsg { get; set; }
		public static Deflate Deflate { get; private set; }

		public Patcher()
		{
			ErrorMsg = "";
		}
		/// <summary>
		/// 언어팩을 적용합니다
		/// </summary>
		/// <param name="TargetPath">게임이 설치되어있는 경로</param>
		public static bool PatchLanguage(string TargetPath)
		{
			var CyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low", "Cygames");

			if (!Directory.Exists(Path.Combine(CyPath, "Shadowverse")))
			{
				ErrorMsg = "패치 대상 폴더가 존재하지않습니다";
				return false;
			}

			if (File.Exists(Path.Combine(MainFolder, "Patch", "ko-kr.zip")))
			{
				var patch_temp_path = Path.Combine(MainFolder, "Patch", "temp");

				if (!Directory.Exists(patch_temp_path))
					Directory.CreateDirectory(patch_temp_path);

				Deflate.Current.ExtractZip(Path.Combine(MainFolder, "Patch", "ko-kr.zip"), patch_temp_path);
				Console.WriteLine("압축해제 완료");

				Deflate.Current.CopyFolder(Path.Combine(MainFolder, "Patch", "temp", "Shadowverse"), Path.Combine(CyPath, "Shadowverse"));

				var datapath = Path.Combine(TargetPath, "Shadowverse_Data");
				if (!Directory.Exists(datapath))
				{
					ErrorMsg = "패치 대상 폴더가 존재하지않습니다";
					return false;
				}

				File.Copy(Path.Combine(MainFolder, "Patch", "temp", "resources.assets"), Path.Combine(datapath, "resources.assets"), true);


				if (Directory.Exists(patch_temp_path))
					Directory.Delete(patch_temp_path, true);
			}
			else
			{
				ErrorMsg = "패치 파일이 없습니다";
				return false;
			}

			return true;
		}
		/// <summary>
		/// 원본 원어팩을 재적용합니다.
		/// </summary>
		/// <param name="TargetPath">게임이 설치되어있는 경로</param>
		public static bool RollbackLanguage(string TargetPath)
		{
			var CyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low", "Cygames");

			if (!Directory.Exists(Path.Combine(CyPath, "Shadowverse")))
			{
				ErrorMsg = "롤백 대상 폴더가 존재하지않습니다";
				return false;
			}

			if (File.Exists(Path.Combine(MainFolder, "Patch", "ko-kr.zip")))
			{
				var patch_temp_path = Path.Combine(MainFolder, "Patch", "temp");

				if (!Directory.Exists(patch_temp_path))
					Directory.CreateDirectory(patch_temp_path);

				Deflate.Current.ExtractZip(Path.Combine(MainFolder, "Patch", "ko-kr.zip"), patch_temp_path);

				//패치 파일을 삭제
				if (Directory.Exists(Path.Combine(patch_temp_path, "Shadowverse")))
					Directory.Delete(Path.Combine(patch_temp_path, "Shadowverse"), true);

				if (File.Exists(Path.Combine(patch_temp_path, "resources.assets")))
					File.Delete(Path.Combine(patch_temp_path, "resources.assets"));

				Deflate.Current.ExtractZip(Path.Combine(MainFolder, "Patch", "temp", "Shadowverse_jp_origin.zip"), patch_temp_path);
				Console.WriteLine("압축해제 완료");

				Deflate.Current.CopyFolder(Path.Combine(MainFolder, "Patch", "temp", "Shadowverse"), Path.Combine(CyPath, "Shadowverse"));

				var datapath = Path.Combine(TargetPath, "Shadowverse_Data");
				if (!Directory.Exists(datapath))
				{
					ErrorMsg = "패치 대상 폴더가 존재하지않습니다";
					return false;
				}

				File.Copy(Path.Combine(MainFolder, "Patch", "temp", "resources.assets"), Path.Combine(datapath, "resources.assets"), true);


				if (Directory.Exists(patch_temp_path))
					Directory.Delete(patch_temp_path, true);
			}
			else
			{
				ErrorMsg = "패치 파일이 없습니다";
				return false;
			}

			return true;
		}
		/// <summary>
		/// dll파일을 바꿔치기하여 영/일 스위칭을 합니다.
		/// </summary>
		/// <param name="TargetPath"></param>
		/// <param name="TargetLanguage">타겟 언어를 설정합니다</param>
		public static bool SwitchingLanguage(string TargetPath, bool IsEnglish)
		{
			return true;
		}
	}
}<commit_msg>교체 파트<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ShadowShifter
{
	public class Patcher
	{
		public static string MainFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);

		public static string ErrorMsg { get; set; }
		public static Deflate Deflate { get; private set; }

		public Patcher()
		{
			ErrorMsg = "";
		}
		/// <summary>
		/// 언어팩을 적용합니다
		/// </summary>
		/// <param name="TargetPath">게임이 설치되어있는 경로</param>
		public static bool PatchLanguage(string TargetPath)
		{
			var CyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low", "Cygames");

			if (!Directory.Exists(Path.Combine(CyPath, "Shadowverse")))
			{
				ErrorMsg = "패치 대상 폴더가 존재하지않습니다";
				return false;
			}

			if (File.Exists(Path.Combine(MainFolder, "Patch", "ko-kr.zip")))
			{
				var patch_temp_path = Path.Combine(MainFolder, "Patch", "temp");

				if (!Directory.Exists(patch_temp_path))
					Directory.CreateDirectory(patch_temp_path);

				Deflate.Current.ExtractZip(Path.Combine(MainFolder, "Patch", "ko-kr.zip"), patch_temp_path);
				Console.WriteLine("압축해제 완료");

				Deflate.Current.CopyFolder(Path.Combine(MainFolder, "Patch", "temp", "Shadowverse"), Path.Combine(CyPath, "Shadowverse"));

				var datapath = Path.Combine(TargetPath, "Shadowverse_Data");
				if (!Directory.Exists(datapath))
				{
					ErrorMsg = "패치 대상 폴더가 존재하지않습니다";
					return false;
				}

				File.Copy(Path.Combine(MainFolder, "Patch", "temp", "resources.assets"), Path.Combine(datapath, "resources.assets"), true);


				if (Directory.Exists(patch_temp_path))
					Directory.Delete(patch_temp_path, true);
			}
			else
			{
				ErrorMsg = "패치 파일이 없습니다";
				return false;
			}

			return true;
		}
		/// <summary>
		/// 원본 원어팩을 재적용합니다.
		/// </summary>
		/// <param name="TargetPath">게임이 설치되어있는 경로</param>
		public static bool RollbackLanguage(string TargetPath)
		{
			var CyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "Low", "Cygames");

			if (!Directory.Exists(Path.Combine(CyPath, "Shadowverse")))
			{
				ErrorMsg = "롤백 대상 폴더가 존재하지않습니다";
				return false;
			}

			if (File.Exists(Path.Combine(MainFolder, "Patch", "ko-kr.zip")))
			{
				var patch_temp_path = Path.Combine(MainFolder, "Patch", "temp");

				if (!Directory.Exists(patch_temp_path))
					Directory.CreateDirectory(patch_temp_path);

				Deflate.Current.ExtractZip(Path.Combine(MainFolder, "Patch", "ko-kr.zip"), patch_temp_path);

				//패치 파일을 삭제
				if (Directory.Exists(Path.Combine(patch_temp_path, "Shadowverse")))
					Directory.Delete(Path.Combine(patch_temp_path, "Shadowverse"), true);

				if (File.Exists(Path.Combine(patch_temp_path, "resources.assets")))
					File.Delete(Path.Combine(patch_temp_path, "resources.assets"));

				Deflate.Current.ExtractZip(Path.Combine(MainFolder, "Patch", "temp", "Shadowverse_jp_origin.zip"), patch_temp_path);
				Console.WriteLine("압축해제 완료");

				Deflate.Current.CopyFolder(Path.Combine(MainFolder, "Patch", "temp", "Shadowverse"), Path.Combine(CyPath, "Shadowverse"));

				var datapath = Path.Combine(TargetPath, "Shadowverse_Data");
				if (!Directory.Exists(datapath))
				{
					ErrorMsg = "패치 대상 폴더가 존재하지않습니다";
					return false;
				}

				File.Copy(Path.Combine(MainFolder, "Patch", "temp", "resources.assets"), Path.Combine(datapath, "resources.assets"), true);


				if (Directory.Exists(patch_temp_path))
					Directory.Delete(patch_temp_path, true);
			}
			else
			{
				ErrorMsg = "패치 파일이 없습니다";
				return false;
			}

			return true;
		}
		/// <summary>
		/// dll파일을 바꿔치기하여 영/일 스위칭을 합니다.
		/// </summary>
		/// <param name="TargetPath"></param>
		/// <param name="TargetLanguage">타겟 언어를 설정합니다</param>
		public static bool SwitchingLanguage(string TargetPath, bool IsEnglish)
		{
			var dllpath = Path.Combine(MainFolder, "dll");
			var jppath = Path.Combine(MainFolder, "dll", "jp");
			var enpath = Path.Combine(MainFolder, "dll", "en");
			var datapath = Path.Combine(TargetPath, "Shadowverse_Data", "Managed");

			string path = enpath;

			if (!Directory.Exists(dllpath) ||
				!Directory.Exists(jppath) ||
				!Directory.Exists(enpath))
			{
				ErrorMsg = "언어 교체 파일이 없습니다";
				return false;
			}

			if (!IsEnglish) path = jppath;

			if (!File.Exists(Path.Combine(path, "Assembly-CSharp.dll")) ||
				!File.Exists(Path.Combine(path, "Assembly-CSharp-firstpass.dll")))
			{
				ErrorMsg = "언어 교체 파일이 없습니다";
				return false;
			}

			File.Copy(Path.Combine(path, "Assembly-CSharp.dll"), Path.Combine(datapath, "Assembly-CSharp.dll"),true);
			File.Copy(Path.Combine(path, "Assembly-CSharp-firstpass.dll"), Path.Combine(datapath, "Assembly-CSharp-firstpass.dll"), true);

			return true;
		}
	}
}
{'fraction_non_alphanumeric': 0.15108239827722997, 'fraction_numerical': 0.0, 'mean_word_length': 3.9768753525098703, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, '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': '2231271', 'n_tokens_mistral': 3805, 'n_tokens_neox': 3476, 'n_words': 559}