Skip to content

Instantly share code, notes, and snippets.

@rakisaionji
Created January 10, 2022 06:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rakisaionji/9c2b20f7ba03e5cfcabff8dcf09198b9 to your computer and use it in GitHub Desktop.
Save rakisaionji/9c2b20f7ba03e5cfcabff8dcf09198b9 to your computer and use it in GitHub Desktop.
Converting a file list with CRC32 checksum data to a SFV checksum file.
using System;
using System.IO;
class Program
{
static void Main(string[] args)
{
var listFile = "list.txt";
var hashFile = "crc32.sfv";
const string assetDir = "assets";
var listFileInfo = new FileInfo(listFile);
if (!listFileInfo.Exists)
{
Console.WriteLine("Assets List not found");
return;
}
using (var input = new StreamReader(listFile))
using (var output = new StreamWriter(hashFile, false))
{
while (!input.EndOfStream)
{
var line = input.ReadLine().Trim();
var part = line.Split(new char[] { '\t' });
if (part.Length < 7) continue;
var path = part[0].Trim();
var hash = part[6].Trim();
if (String.IsNullOrEmpty(path) || String.IsNullOrEmpty(hash)) continue;
path = Path.Combine(assetDir, path);
if (hash.Length < 8) hash = hash.PadLeft(8, '0');
output.WriteLine("{0}\t{1}", path, hash);
}
}
Console.WriteLine("DONE!");
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment