/// <summary> /// Adds the set of files to the specified directory element. Each file /// gets its own parent component element. /// </summary> void AddFiles(WixDirectoryElement directoryElement, string directory) { foreach (string fileName in DirectoryReader.GetFiles(directory)) { if (!excludedNames.IsExcluded(fileName)) { string path = Path.Combine(directory, fileName); AddFileWithParentComponent(directoryElement, path); } } }
/// <summary> /// Compares the files defined in the WixDirectoryElement against those /// on the file system and returns any differences. /// </summary> public WixPackageFilesDiffResult[] Compare(WixDirectoryElementBase directoryElement) { List <string> wixPackageFiles = GetAllFiles(directoryElement); List <string> files = new List <string>(); // Find all files on the file system based on the directories // used in the Wix document. searchedDirectories = new List <string>(); foreach (string fileName in wixPackageFiles) { string directory = Path.GetDirectoryName(fileName); if (!HasDirectoryBeenSearched(directory)) { if (directoryReader.DirectoryExists(directory)) { foreach (string directoryFileName in directoryReader.GetFiles(directory)) { if (!excludedFileNames.IsExcluded(directoryFileName)) { files.Add(Path.Combine(directory, directoryFileName)); } } } } } // Look for new files. List <string> missingFiles = new List <string>(); List <string> removedFiles = new List <string>(); foreach (string fileName in wixPackageFiles) { int index = GetFileNameIndex(files, fileName); if (index >= 0) { removedFiles.Add(files[index]); files.RemoveAt(index); } else { // Check that this file has not already been removed. index = GetFileNameIndex(removedFiles, fileName); if (index == -1) { missingFiles.Add(fileName); } } } // Add new files. List <WixPackageFilesDiffResult> results = new List <WixPackageFilesDiffResult>(); foreach (string fileName in files) { results.Add(new WixPackageFilesDiffResult(fileName, WixPackageFilesDiffResultType.NewFile)); } // Add missing files. foreach (string fileName in missingFiles) { results.Add(new WixPackageFilesDiffResult(fileName, WixPackageFilesDiffResultType.MissingFile)); } // Add new directories. results.AddRange(GetNewDirectories()); return(results.ToArray()); }