Init
This commit is contained in:
commit
fe529af769
10
CodeSigner.csproj
Normal file
10
CodeSigner.csproj
Normal file
@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
44
Program.cs
Normal file
44
Program.cs
Normal file
@ -0,0 +1,44 @@
|
||||
const string AuthorName = "Syntriax";
|
||||
const string AuthorEmail = "Syntriax@gmail.com";
|
||||
|
||||
const string FileSearchPattern = "*.cs";
|
||||
const string ProgramSignature = $"Signed by an automated program written by Syntriax";
|
||||
const string CreationDateTag = "<CreationDate>";
|
||||
const string Signature =
|
||||
$@"/*
|
||||
Author: {AuthorName}
|
||||
Email: {AuthorEmail}
|
||||
Creation Date: {CreationDateTag} UTC
|
||||
{ProgramSignature}
|
||||
*/
|
||||
";
|
||||
|
||||
void ExploreDirectory(string path)
|
||||
{
|
||||
string[] files = Directory.GetFiles(path, FileSearchPattern);
|
||||
string[] directories = Directory.GetDirectories(path);
|
||||
|
||||
foreach (string filePath in files)
|
||||
Sign(filePath);
|
||||
|
||||
foreach (string directoryPath in directories)
|
||||
ExploreDirectory(directoryPath);
|
||||
}
|
||||
|
||||
void Sign(string filePath)
|
||||
{
|
||||
string[] lines = File.ReadAllLines(filePath);
|
||||
|
||||
foreach (string line in lines)
|
||||
if (line.Contains(ProgramSignature))
|
||||
return;
|
||||
|
||||
Console.WriteLine($"Signing -> {filePath}");
|
||||
DateTime dateTime = File.GetCreationTimeUtc(filePath);
|
||||
string newContents = Signature.Replace(CreationDateTag, $"{dateTime.ToLongDateString()} - {dateTime.ToLongTimeString()}");
|
||||
newContents += File.ReadAllText(filePath);
|
||||
File.WriteAllText(filePath, newContents);
|
||||
}
|
||||
|
||||
ExploreDirectory(Environment.GetCommandLineArgs()[1]);
|
||||
Console.ReadKey();
|
Loading…
x
Reference in New Issue
Block a user