preliminary implementation of 'ue --find-checksum' command

This commit is contained in:
Michael Becker 2020-08-28 17:05:29 -04:00
parent 2048e911e8
commit 2c53ac1c96
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7
2 changed files with 52 additions and 2 deletions

View File

@ -30,9 +30,9 @@ namespace UniversalEditor.ConsoleApplication
{
if (args.Length > 0)
{
if (args[0] == "update-associations")
if (args[0] == "--update-associations")
{
StringBuilder sb = new StringBuilder ();
StringBuilder sb = new StringBuilder();
sb.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
sb.AppendLine("<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">");
DataFormatReference[] dfrs = UniversalEditor.Common.Reflection.GetAvailableDataFormats();
@ -90,6 +90,48 @@ namespace UniversalEditor.ConsoleApplication
}
return;
}
else if (args[0] == "--find-checksum")
{
if (args.Length > 0)
{
Console.WriteLine("looking for {0}", args[1]);
Checksum.Modules.Adler32.Adler32 adlr = new Checksum.Modules.Adler32.Adler32();
string[] files = new string[args.Length - 2];
for (int i = 2; i <args.Length; i++)
{
files[i - 2] = args[i];
}
Type[] types = MBS.Framework.Reflection.GetAvailableTypes(new Type[] { typeof(Checksum.ChecksumModule) });
for (int i = 0; i < types.Length; i++)
{
Checksum.ChecksumModule module = (types[i].Assembly.CreateInstance(types[i].FullName) as Checksum.ChecksumModule);
if (module == null) continue;
Console.WriteLine("=== {0} ===", module.GetType().Name);
for (int j = 0; j < files.Length; j++)
{
Console.Write(System.IO.Path.GetFileName(files[j]).PadRight(30));
if (System.IO.File.Exists(files[j]))
{
long calc = module.Calculate(System.IO.File.ReadAllBytes(files[j]));
calc = (int)(calc);
Console.Write(calc.ToString());
}
else
{
Console.Write("NOT FOUND");
}
// Console.Write(calc.ToString("x"));
Console.WriteLine();
}
Console.WriteLine();
}
}
}
}
return;

View File

@ -44,6 +44,14 @@
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Checksum\UniversalEditor.Checksum.csproj">
<Project>{0F7D5BD4-7970-412F-ABD7-0A098BB01ACE}</Project>
<Name>UniversalEditor.Checksum</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework\MBS.Framework\MBS.Framework.csproj">
<Project>{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>