Skip to content

Commit 6fab9b9

Browse files
committed
WizardWindow: generate ReducePathMap.log file in the output directory to record the mapping of hash and prefix paths
1 parent e1b88f7 commit 6fab9b9

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

OKEGui/OKEGui/Gui/WizardWindow.xaml.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.ComponentModel;
55
using System.IO;
66
using System.Linq;
7+
using System.Text;
78
using System.Text.RegularExpressions;
89
using System.Windows;
910
using System.Windows.Forms;
@@ -225,6 +226,7 @@ private void WizardFinish(object sender, RoutedEventArgs e)
225226
// 2、新建脚本文件
226227
// 3、新建任务参数
227228
Cleaner cleaner = new Cleaner();
229+
Dictionary<uint, string> reducePathHashMap = new Dictionary<uint, string>();
228230
foreach (string inputFile in wizardInfo.InputFile)
229231
{
230232
List<TaskDetail> existing = workerManager.tm.GetTasksByInputFile(inputFile);
@@ -290,9 +292,13 @@ private void WizardFinish(object sender, RoutedEventArgs e)
290292
else
291293
{
292294
// By default, the last level path is preserved and the crc of the prefix path is added to prevent naming conflicts.
293-
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(effectivePathPrefix);
295+
byte[] buffer = Encoding.UTF8.GetBytes(effectivePathPrefix);
294296
var crc = CRC32.Compute(buffer);
295297
newEffectivePath = crc.ToString("X8") + "-" + effectivePathLast;
298+
if (!reducePathHashMap.ContainsKey(crc))
299+
{
300+
reducePathHashMap.Add(crc, effectivePathPrefix);
301+
}
296302
}
297303
string[] newInputSuffixComponents = new string[] {inputSuffixComponents[0], newEffectivePath, inputSuffixComponents[inputSuffixComponents.Length - 1]};
298304
inputSuffixPath = string.Join("\\", newInputSuffixComponents);
@@ -353,6 +359,18 @@ private void WizardFinish(object sender, RoutedEventArgs e)
353359

354360
workerManager.AddTask(td);
355361
}
362+
363+
// 输出缩减路径后的hash映射关系
364+
string reducePathMapFile = new DirectoryInfo(wizardInfo.ProjectFile).Parent.FullName + "\\output\\" + "ReducePathMap.log";
365+
if (Initializer.Config.reducePath && reducePathHashMap.Count > 0)
366+
{
367+
string reducePathMapContent = "";
368+
foreach (KeyValuePair<uint, string> kvp in reducePathHashMap)
369+
{
370+
reducePathMapContent += kvp.Key.ToString("X8") + " " + kvp.Value + Environment.NewLine;
371+
}
372+
File.AppendAllText(reducePathMapFile, reducePathMapContent);
373+
}
356374
}
357375
catch (Exception ex)
358376
{

0 commit comments

Comments
 (0)