Skip to content

Commit

Permalink
处理文件不存在但是希望打补丁的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyadanli committed Jun 14, 2024
1 parent 8b63257 commit 344f2f7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion RevokeMsgPatcher/Modifier/QQNTModifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,14 @@ public override void AfterPatchSuccess()
string content = File.ReadAllText(indexPath);
// 正则 require\(String.raw`.*`\);
string pattern = @"require\(String.raw`.*`\);";
string replacement = $"require(String.raw`{GetLiteLoaderPath()}`);";
string liteLoaderPath = GetLiteLoaderPath();
if (!File.Exists(liteLoaderPath))
{
MessageBox.Show("LiteLoaderQQNT文件夹不存在,仅安装QQNT去验证补丁", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}

string replacement = $"require(String.raw`{liteLoaderPath}`);";
if (Regex.IsMatch(content, pattern))
{
content = Regex.Replace(content, pattern, replacement);
Expand Down

0 comments on commit 344f2f7

Please sign in to comment.