private void ProcessFilesByMediaDisk(ICollection<string> fileKeys, ProcessFilesOnOneMediaDiskHandler diskHandler) { if(this.IsMergeModule()) { InstallPathMap files = new InstallPathMap(); foreach(string fileKey in this.Files.Keys) { if(fileKeys == null || fileKeys.Contains(fileKey)) { files[fileKey] = this.Files[fileKey]; } } diskHandler("#MergeModule.CABinet", files, new InstallPathMap()); } else { bool defaultCompressed = ((this.SummaryInfo.WordCount & 0x2) != 0); View fileView = null, mediaView = null; Record fileRec = null; try { fileView = this.OpenView("SELECT `File`, `Attributes`, `Sequence` " + "FROM `File` ORDER BY `Sequence`"); mediaView = this.OpenView("SELECT `DiskId`, `LastSequence`, `Cabinet` " + "FROM `Media` ORDER BY `DiskId`"); fileView.Execute(); mediaView.Execute(); int currentMediaDiskId = -1; int currentMediaMaxSequence = -1; string currentMediaCab = null; InstallPathMap compressedFileMap = new InstallPathMap(); InstallPathMap uncompressedFileMap = new InstallPathMap(); while((fileRec = fileView.Fetch()) != null) { string fileKey = (string) fileRec[1]; if(fileKeys == null || fileKeys.Contains(fileKey)) { int fileAttributes = fileRec.GetInteger(2); int fileSequence = fileRec.GetInteger(3); InstallPath fileInstallPath = this.Files[fileKey]; if(fileInstallPath == null) { this.LogMessage("Could not get install path for source file: {0}", fileKey); throw new InstallerException("Could not get install path for source file: " + fileKey); } if(fileSequence > currentMediaMaxSequence) { if(currentMediaDiskId != -1) { diskHandler(currentMediaCab, compressedFileMap, uncompressedFileMap); compressedFileMap.Clear(); uncompressedFileMap.Clear(); } while(fileSequence > currentMediaMaxSequence) { Record mediaRec = mediaView.Fetch(); if(mediaRec == null) { currentMediaDiskId = -1; break; } using(mediaRec) { currentMediaDiskId = mediaRec.GetInteger(1); currentMediaMaxSequence = mediaRec.GetInteger(2); currentMediaCab = (string) mediaRec[3]; } } if(fileSequence > currentMediaMaxSequence) break; } if((fileAttributes & (int) Microsoft.Deployment.WindowsInstaller.FileAttributes.Compressed) != 0) { compressedFileMap[fileKey] = fileInstallPath; } else if ((fileAttributes & (int) Microsoft.Deployment.WindowsInstaller.FileAttributes.NonCompressed) != 0) { // Non-compressed files are located // in the same directory as the MSI, without any path. uncompressedFileMap[fileKey] = new InstallPath(fileInstallPath.SourceName); } else if(defaultCompressed) { compressedFileMap[fileKey] = fileInstallPath; } else { uncompressedFileMap[fileKey] = fileInstallPath; } } fileRec.Close(); fileRec = null; } if(currentMediaDiskId != -1) { diskHandler(currentMediaCab, compressedFileMap, uncompressedFileMap); } } finally { if (fileRec != null) fileRec.Close(); if (fileView != null) fileView.Close(); if (mediaView != null) mediaView.Close(); } } }