/// <summary> /// Initialize new instance of <see cref="HashDatabaseWriter"/> with specified hash type. /// </summary> /// <param name="outputPath">Fullpath output directory.</param> /// <param name="fileName">Database file name (without extension, the extension will selected automatically).</param> /// <param name="type">Hash type.</param> /// <param name="append">Specifies that this writer is appending not overwriting.</param> public HashDatabaseWriter(string outputPath, string fileName, DatabaseType type, bool append) { ArgValidate.NotEmptyString(outputPath, nameof(outputPath)); ArgValidate.DirectoryExist(outputPath, nameof(outputPath)); ArgValidate.NotEmptyString(fileName, nameof(fileName)); ArgValidate.FileExist(fileName, nameof(fileName)); var fname = string.Copy(fileName); switch (type) { case DatabaseType.Sha1Hash: fname += ".hsb"; break; case DatabaseType.Sha256Hash: fname += ".hsb"; break; case DatabaseType.Md5Hash: fname += ".hdb"; break; case DatabaseType.PeSectionHash: fname += ".msb"; break; } _type = type; _writer = new StreamWriter(Path.Combine(outputPath, fname), append) { NewLine = "\n" }; }
/// <summary> /// Initialize new instance of <see cref="DatabaseStateChecker"/> using specified directory to watch. /// </summary> /// <param name="dirPath">Full path to database directory.</param> public DatabaseStateChecker(string dirPath) { ArgValidate.NotEmptyString(dirPath, nameof(dirPath)); ArgValidate.DirectoryExist(dirPath, nameof(dirPath)); _dirPath = dirPath; }