Files
poli0981andClaude Opus 5.5 eaaf6198a4 feat(core): hashing engine, checksum files, safe folder walking, settings store
HashTool.Core now holds everything that does not need a UI:
- HashEngine reads a file once for any number of algorithms, overlaps disk
  reads with hashing (double buffering), uses BLAKE3's multi-threaded mode
  for large blocks and opens files with FileShare.ReadWrite|Delete so files
  still open in another program can be hashed.
- CRC-32 is now printed in the conventional big-endian order (CBF43926 for
  "123456789"); HashMatcher still accepts the reversed values written by 1.x.
- ChecksumParser reads GNU (sha256sum), BSD/--tag, xxhsum, SFV, bare 1.x
  sidecars and certutil output, including UTF-16 files; ChecksumWriter writes
  GNU, BSD, SFV, JSON and CSV (formula-injection safe). Network (UNC) and
  device paths inside checksum files are never resolved.
- ChecksumFileNames recognises checksum files by extension and *SUMS names
  instead of Enum.TryParse, which accepted numeric extensions like .001.
- FileEnumerator walks folders on a background-friendly lazy enumerator,
  skips unreadable folders and does not follow symbolic links or junctions
  (the old walker looped forever on link cycles).
- BatchProcessor runs small files in parallel and large files in their own
  lane, with per-file cancellation and timeouts, and reports every item once.
- SettingsStore saves atomically, recovers from corrupt files (keeps a .bak),
  clamps values, reads 1.x files and imports font_settings.json, which 1.1.x
  used as the only store for font choices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 13:16:40 +07:00

38 lines
1.0 KiB
C#

using System;
using System.IO;
using System.Text;
namespace HashTool.Core.Tests;
/// <summary>A temporary directory deleted when the test finishes.</summary>
public sealed class TempDirectory : IDisposable
{
public TempDirectory() => Info = Directory.CreateTempSubdirectory("hashtool-tests-");
public DirectoryInfo Info { get; }
public string Path => Info.FullName;
public string File(string relativePath, byte[] content)
{
var full = System.IO.Path.GetFullPath(System.IO.Path.Combine(Path, relativePath));
Directory.CreateDirectory(System.IO.Path.GetDirectoryName(full)!);
System.IO.File.WriteAllBytes(full, content);
return full;
}
public string File(string relativePath, string content) => File(relativePath, Encoding.UTF8.GetBytes(content));
public void Dispose()
{
try
{
Info.Delete(recursive: true);
}
catch (IOException)
{
// Best effort; the OS cleans the temp folder eventually.
}
}
}