FileEntry CreateFileEntry(string file, bool shouldHash) { var fi = new FileInfo(file); var fe = new FileEntry(); fe.Length = fi.Length; fe.Timestamp = fi.LastWriteTimeUtc; if (shouldHash) fe.Hash = HashFile(fi); return fe; }
bool CheckChanged(ChangeDetection detection, FileInfo file, FileEntry entry) { if (!file.Exists) return true; if ((detection & ChangeDetection.Length) != 0 && file.Length != entry.Length) return true; if ((detection & ChangeDetection.Timestamp) != 0 && file.LastWriteTimeUtc != entry.Timestamp) return true; if ((detection & ChangeDetection.Hash) != 0 && HashFile(file) != entry.Hash) return true; return false; }