Skip to content

Commit 21e6530

Browse files
committed
Add command line option / CRC32 Check
Added command line option to toggle generating GIF. CRC32 Check status is displayed during execution.
1 parent 3fbd893 commit 21e6530

File tree

1 file changed

+24
-1
lines changed
  • NotepadStateLibrary/WindowsNotepadParser

1 file changed

+24
-1
lines changed

NotepadStateLibrary/WindowsNotepadParser/Program.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
using CommandLine;
55
using WindowsNotepadParser;
66
using System.IO.Compression;
7+
using System.ComponentModel.DataAnnotations;
8+
using CsvHelper.Configuration;
9+
using System.Diagnostics;
710

811
Parser.Default.ParseArguments<Options>(args)
912
.WithParsed(options =>
1013
{
1114
string tabStateLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Packages\Microsoft.WindowsNotepad_8wekyb3d8bbwe\LocalState\TabState");
1215
string windowStateLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Packages\Microsoft.WindowsNotepad_8wekyb3d8bbwe\LocalState\WindowState");
1316
string outputLocation = Directory.GetCurrentDirectory();
17+
bool generateGif = options.generateGif;
1418

1519
if (!string.IsNullOrWhiteSpace(options.tabStateLocation))
1620
{
@@ -26,6 +30,14 @@
2630
}
2731

2832
Console.WriteLine("********** Starting **********");
33+
34+
//TODO: Detect version of Notepad
35+
36+
//string exeLocation = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\WindowsApps\Microsoft.WindowsNotepad_8wekyb3d8bbwe\notepad.exe");
37+
//FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(exeLocation);
38+
//string fileVersion = versionInfo.FileVersion;
39+
//Console.WriteLine("Version: {0}", fileVersion);
40+
2941
Console.WriteLine("TabState Folder Location - {0}", tabStateLocation);
3042
if (!Directory.Exists(tabStateLocation))
3143
{
@@ -98,8 +110,14 @@
98110
}
99111
}
100112

101-
ContentToImage ci = new ContentToImage(np.Content, np.UnsavedBufferChunks,string.Format("{0}.gif", Path.GetFileNameWithoutExtension(path)));
113+
if (generateGif)
114+
{
115+
Console.WriteLine("Generating Unsaved Buffer Chunks GIF for TabState - {0}", Path.GetFileName(path));
116+
ContentToImage ci = new ContentToImage(np.Content, np.UnsavedBufferChunks, string.Format("{0}.gif", Path.GetFileNameWithoutExtension(path)));
117+
}
102118
}
119+
120+
Console.WriteLine("CRC32 Check Pass: {0}", np.CRC32Calculated.SequenceEqual(np.CRC32Stored));
103121
}
104122
}
105123
}
@@ -153,6 +171,8 @@
153171
Console.WriteLine("Processing WindowState - {0}", Path.GetFileName(path));
154172
NPWindowState np = new NPWindowState(data, Path.GetFileName(path));
155173
windowStateTabs.Add(np);
174+
175+
Console.WriteLine("CRC32 Check Pass: {0}", np.CRC32Calculated.SequenceEqual(np.CRC32Stored));
156176
}
157177
}
158178
}
@@ -215,4 +235,7 @@ public class Options
215235

216236
[Option('o', "outputlocation", Required = false, HelpText = "Output Folder Location for CSV files. Default location is same folder as program.")]
217237
public string outputLocation { get; set; }
238+
239+
[Option('g', "generategif" , Default = false, Required = false, HelpText = "Generate GIF images of Unsaved Buffer Chunks. Default is false.")]
240+
public bool generateGif { get; set; }
218241
}

0 commit comments

Comments
 (0)