元ファイルの同一性の型を追加する

このコミットが含まれているのは:
routersys committed 2026-09-13 17:52:27 +09:00
1 親 a624667006
コミット 0f68e04cd8
1ファイル変更
+30
+30
ファイルの表示
@@ -0,0 +1,30 @@
using System.IO;
namespace ProxyForge.Cache;
internal readonly record struct SourceIdentity(string Path, long Length, long WriteTimeTicks)
{
public static SourceIdentity? Of(string path)
{
string fullPath;
try
{
fullPath = System.IO.Path.GetFullPath(path);
}
catch (Exception exception) when (exception is ArgumentException or PathTooLongException or NotSupportedException)
{
return null;
}
var file = new FileInfo(fullPath);
if (!file.Exists)
return null;
return new SourceIdentity(fullPath, file.Length, file.LastWriteTimeUtc.Ticks);
}
public bool Matches(string path, long length, long writeTimeTicks)
=> Length == length
&& WriteTimeTicks == writeTimeTicks
&& string.Equals(Path, path, StringComparison.OrdinalIgnoreCase);
}