Scripts for dealing with table stuff

This commit is contained in:
Kyle Belanger 2024-04-11 01:19:09 -04:00
parent db41e1c69e
commit 8f7dd7993f
2 changed files with 48 additions and 0 deletions

28
Scripts/CopyTables.cs Normal file
View File

@ -0,0 +1,28 @@
using System;
using System.IO;
static readonly string NewTableDir = @"table";
static readonly string OldTableDir = @"..\Resources\table";
// Copy the new tables over the old tables
foreach (var filename in Directory.GetFiles(OldTableDir, "*.tsv", SearchOption.AllDirectories))
{
var newFilename = filename.Replace(OldTableDir, NewTableDir);
if (!File.Exists(newFilename))
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"WARNING: New table does not exist! {newFilename}");
Console.ResetColor();
continue;
}
if (File.Exists(filename))
File.Delete(filename);
File.Copy(newFilename, filename);
Console.WriteLine($"Copied {newFilename} to {filename}");
}
Console.WriteLine("Done!");

20
Scripts/ProcessTables.cs Normal file
View File

@ -0,0 +1,20 @@
using System;
using System.IO;
static readonly string TableDir = @"table";
foreach (var filename in Directory.GetFiles(TableDir, "*.tab.bytes", SearchOption.AllDirectories))
{
// Remove the first 128 bytes from the file (signature)
var bytes = File.ReadAllBytes(filename);
var newBytes = new byte[bytes.Length - 128];
Array.Copy(bytes, 128, newBytes, 0, newBytes.Length);
File.WriteAllBytes(filename, newBytes);
// Rename the file to .tsv
File.Move(filename, filename.Replace(".tab.bytes", string.Empty) + ".tsv");
Console.WriteLine($"Processed {filename}");
}
Console.WriteLine("Done!");