namespace AIStudio.Chat; /// /// The state of a file which a text was read from, to tell whether the file changed since. /// /// /// The size counts as well as the time: some file systems keep the time coarsely, e.g., FAT to two /// seconds, and a network drive may report the time of another clock. /// /// When the file was last written. /// The size of the file in bytes. public sealed record FileVersion(DateTime LastWriteUtc, long Length) { /// /// Reads the state of a file as it is now. /// /// The path of the file. /// The state, or null when the file is gone. public static FileVersion? Of(string filePath) { var file = new FileInfo(filePath); return file.Exists ? new(file.LastWriteTimeUtc, file.Length) : null; } }