/// <summary> /// Convenience function that adds a range of files /// </summary> /// <param name="Files"></param> /// <param name="HashType"></param> public bool AddFiles(IEnumerable <FileReference> Files, HashCollection.HashType HashType) { foreach (var File in Files) { if (!AddFile(File, HashType)) { return(false); } } return(true); }
/// <summary> /// Adds a file to our hash collection. If the specified path does not exist an exception /// will be thrown /// </summary> /// <param name="InPath"></param> /// <param name="HashType"></param> public bool AddFile(FileReference InPath, HashCollection.HashType HashType) { var Fi = new FileInfo(InPath.FullName); if (!Fi.Exists) { return(false); } string MetaData = string.Format("File={0} Size={1} LastWrite={2}", InPath, Fi.Length, Fi.LastWriteTimeUtc.ToString()); // Hash metadata or content ContentHash Hash = HashType == HashCollection.HashType.MetaData ? ContentHash.SHA1(MetaData) : ContentHash.SHA1(InPath); HashEntry Entry = new HashEntry(InPath.FullName, Hash, MetaData); Hashes.Add(Entry); return(true); }
/// <summary> /// Adds aall input/output properties of a CSProject to a hash collection /// </summary> /// <param name="Hasher"></param> /// <param name="Project"></param> /// <returns></returns> public static bool AddCsProjectInfo(this HashCollection Hasher, CsProjectInfo Project, HashCollection.HashType HashType) { // Get the output assembly and pdb file DirectoryReference ProjectDirectory = Project.ProjectPath.Directory; DirectoryReference OutputDir = Project.GetOutputDir(ProjectDirectory); FileReference OutputFile = FileReference.Combine(OutputDir, Project.GetAssemblyName() + ".dll"); FileReference DebugFile = OutputFile.ChangeExtension("pdb"); // build a list of all input and output files from this module List <FileReference> DependentFiles = new List <FileReference> { Project.ProjectPath, OutputFile, DebugFile }; DependentFiles.AddRange(Project.CompileReferences); if (!Hasher.AddFiles(DependentFiles, HashType)) { return(false); } return(true); }
/// <summary> /// Adds aall input/output properties of a CSProject to a hash collection /// </summary> /// <param name="Hasher"></param> /// <param name="Project"></param> /// <returns></returns> public static bool AddCsProjectInfo(this HashCollection Hasher, CsProjectInfo Project, HashCollection.HashType HashType) { // Get the output assembly and pdb file FileReference OutputFile; if(!Project.TryGetOutputFile(out OutputFile)) { throw new Exception(String.Format("Unable to get output file for {0}", Project.ProjectPath)); } FileReference DebugFile = OutputFile.ChangeExtension("pdb"); // build a list of all input and output files from this module List<FileReference> DependentFiles = new List<FileReference> { Project.ProjectPath, OutputFile, DebugFile }; DependentFiles.AddRange(Project.CompileReferences); if (!Hasher.AddFiles(DependentFiles, HashType)) { return false; } return true; }