private XenServerPatchAlert GetAlertFromIsoFile(string fileName, out bool hasUpdateXml, out bool isUpgradeIso) { hasUpdateXml = false; isUpgradeIso = false; if (!fileName.EndsWith(InvisibleMessages.ISO_UPDATE)) { return(null); } var xmlDoc = new XmlDocument(); try { using (var isoStream = File.OpenRead(fileName)) { var cd = new CDReader(isoStream, true); if (cd.Exists("Update.xml")) { using (var fileStream = cd.OpenFile("Update.xml", FileMode.Open)) { xmlDoc.Load(fileStream); hasUpdateXml = true; } } if (cd.Exists(@"repodata\repomd.xml") && cd.FileExists(".treeinfo")) { using (var fileStream = cd.OpenFile(".treeinfo", FileMode.Open)) { var iniDoc = new IniDocument(fileStream); var entry = iniDoc.FindEntry("platform", "name"); if (entry != null && entry.Value == "XCP") { isUpgradeIso = true; return(null); } } } } } catch (Exception exception) { log.Error("Exception while reading the update data from the iso file:", exception); } var elements = xmlDoc.GetElementsByTagName("update"); var update = elements.Count > 0 ? elements[0] : null; if (update == null || update.Attributes == null) { return(null); } var uuid = update.Attributes["uuid"]; return(uuid != null?Updates.FindPatchAlertByUuid(uuid.Value) : null); }
public void ExtractFile(String FileSource, String FileTarget) { FileStream FileISO = File.Open(FileName, FileMode.Open, FileAccess.Read); try { CDReader ReaderISO = new CDReader(FileISO, true); SparseStream _SourceStream = ReaderISO.OpenFile(FileSource, FileMode.Open, FileAccess.Read); Byte[] _ReadAllByte = new Byte[_SourceStream.Length]; _SourceStream.Read(_ReadAllByte, 0, _ReadAllByte.Length); _SourceStream.Close(); FileStream _FileCreated = new FileStream(FileTarget, FileMode.CreateNew); _FileCreated.Position = 0; _FileCreated.Write(_ReadAllByte, 0, _ReadAllByte.Length); _FileCreated.Close(); } catch (IOException ex) { if (ex.Message != "No such file") { Console.WriteLine("-----------------------------------------------------"); Console.WriteLine("ExtractFile(" + FileSource + ", " + FileTarget + ")"); Console.WriteLine(ex.Message); Console.WriteLine("-----------------------------------------------------"); } else { Console.WriteLine("ExtractFile(" + FileSource + ") --> " + Path.GetFileName(FileName)); } } FileISO.Close(); }
public override bool DetectROM(string inputPath, out string titleID, out uint regionID) { regionID = 0; using (FileStream isoStream = File.Open(inputPath, FileMode.Open)) { if (!CDReader.Detect(isoStream)) { titleID = null; return(false); } else { CDReader cd = new CDReader(isoStream, true); titleID = null; bool confirm = false; if (cd.FileExists(@"UMD_DATA.BIN")) { using (StreamReader sr = new StreamReader(cd.OpenFile(@"UMD_DATA.BIN", FileMode.Open))) { titleID = sr.ReadLine().Substring(0, 10); } confirm = true; } cd.Dispose(); return(confirm); } } }
public override byte[] GetFileBin(CompressedFile metadata) { if (!_cd.FileExists(metadata.FullName)) { return(null); } var fs = _cd.OpenFile(metadata.FullName, FileMode.Open, FileAccess.Read); byte[] data; using (var ms = new MemoryStream()) { fs.CopyTo(ms); data = ms.ToArray(); } return(data); }
public static VirtualFileSystemEntry ToVirtualFileSystemEntry(this CDReader isoFileSystem, string path) { if (isoFileSystem.FileExists(path)) { var fileName = Path.GetFileName(path); if (fileName.EndsWith(";1")) { fileName = fileName.Substring(0, fileName.Length - 2); } return(new VirtualFile(null, isoFileSystem.OpenFile(path, FileMode.Open), fileName)); } else { var directory = new VirtualDirectory(null, Path.GetFileName(path)); foreach (var file in isoFileSystem.GetFiles(path)) { var entry = ToVirtualFileSystemEntry(isoFileSystem, file); entry.MoveTo(directory); } foreach (var subDirectory in isoFileSystem.GetDirectories(path)) { var entry = ToVirtualFileSystemEntry(isoFileSystem, subDirectory); entry.MoveTo(directory); } return(directory); } }
private void openIsoToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory; openFileDialog1.Filter = "Sims ps2 Iso (*.iso)|*.iso|All Files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { try { using (FileStream isoStream = File.Open(openFileDialog1.FileName, FileMode.Open)) { CDReader cd = new CDReader(isoStream, true); Stream fileStream = cd.OpenFile(@"default.ngh", FileMode.Open); MessageBox.Show("Iso found " + cd.VolumeLabel); } } catch (Exception ex) { ex = new Exception(); MessageBox.Show("File is not Sims ps2 iso"); } } }
/// <inheritdoc/> public bool HeaderSignatureMatches(Stream romStream) { romStream.Seek(0, SeekOrigin.Begin); var reader = new CDReader(romStream, true); var system = reader.OpenFile("SYSTEM.CNF", FileMode.Open); return(new StreamReader(system).ReadToEnd().Contains("BOOT2")); }
/// <inheritdoc/> public string GetSerial(Stream romStream) { romStream.Seek(0, SeekOrigin.Begin); CDReader reader = new CDReader(romStream, true); var system = reader.OpenFile(@"PSP_GAME\PARAM.SFO", FileMode.Open); var sfo = new SFOReader(system); return(sfo.KeyValues.ContainsKey("DISC_ID") ? sfo.KeyValues["DISC_ID"] : sfo.KeyValues["TITLE_ID"]); }
/// <inheritdoc/> public string GetSerial(Stream romStream) { romStream.Seek(0, SeekOrigin.Begin); var reader = new CDReader(romStream, true); var system = reader.OpenFile("SYSTEM.CNF", FileMode.Open); return(Regex.Match(new StreamReader(system).ReadToEnd(), "[A-Z]+_[0-9][0-9][0-9].[0-9][0-9]", RegexOptions.IgnoreCase).Value.Replace(".", string.Empty).Replace("_", "-")); }
private void extractFile(object sender, EventArgs e) { SaveFileDialog open = new SaveFileDialog { Title = "Extract to..", Filter = "All types|*.*", FileName = usnd.Text }; if (open.ShowDialog() == DialogResult.OK) { FileStream output = new FileStream(open.FileName, FileMode.Create); string path = usnd.Parent.Text + @"\" + usnd.Text; Stream stream = iso.OpenFile(path, FileMode.Open); stream.CopyTo(output); output.Close(); } }
/// <inheritdoc/> public string GetInternalName(Stream romStream) { romStream.Seek(0, SeekOrigin.Begin); CDReader reader = new CDReader(romStream, true); var system = reader.OpenFile(@"PSP_GAME\PARAM.SFO", FileMode.Open); var sfo = new SFOReader(system); return(sfo.KeyValues["TITLE"]); }
public void ExtractISO() { using (FileStream isoStream = File.Open(@"C:\temp\sample.iso", FileMode.Open)) { CDReader cd = new CDReader(isoStream, true); Stream fileStream = cd.OpenFile(@"Folder\Hello.txt", FileMode.Open); // Use fileStream... } }
public static string DetectPs2Sku(FileInfo isofile) { Stream isoStream; if (isBinFile(isofile)) { isoStream = new RawCdRomStream(isofile); } else { isoStream = isofile.OpenRead(); } if (!CDReader.Detect(isoStream)) { return(null); } CDReader cdReader = new CDReader(isoStream, false, true); if (!cdReader.FileExists("SYSTEM.CNF")) { cdReader.Dispose(); isoStream.Dispose(); return(null); } SparseStream systemCnfStream = cdReader.OpenFile("SYSTEM.CNF", FileMode.Open, FileAccess.Read); StreamReader systemCnfReader = new StreamReader(systemCnfStream, Encoding.ASCII); string boot2 = null; while (!systemCnfReader.EndOfStream) { boot2 = systemCnfReader.ReadLine(); if (boot2.ToUpperInvariant().StartsWith("BOOT")) { break; } } systemCnfReader.Dispose(); systemCnfStream.Dispose(); while (boot2.Contains("\\")) { boot2 = boot2.Substring(1); } if (boot2.EndsWith(";1")) { boot2 = boot2.Substring(0, boot2.Length - 2); } cdReader.Dispose(); isoStream.Dispose(); return(boot2); }
/// <summary> /// Retrieve the VOL stream(s) and the corresponding filename. /// </summary> /// <returns></returns> public IEnumerable <(Stream stream, string fileName)> GetStreams() { if (!_parsed) { GetFileType(); } switch (_fileType) { case FileType.TOC31_VOL: yield return(new FileStream(_filePath, FileMode.Open, FileAccess.Read), Path.GetFileName(_filePath)); break; case FileType.TOC31_ISO: using (FileStream isoStream = File.Open(_filePath, FileMode.Open)) { CDReader cd = new CDReader(isoStream, true, true); var nextDescriptor = cd.ClusterSize * cd.TotalClusters; var vols = cd.GetFiles("", "*.*", SearchOption.AllDirectories) .ToList() .Where(x => x.EndsWith(".VOL", StringComparison.OrdinalIgnoreCase)) .ToArray(); foreach (var volFile in vols) { yield return(cd.OpenFile(volFile, FileMode.Open), Path.GetFileName(volFile)); } // Check for second descriptor if (nextDescriptor != isoStream.Length) { isoStream.Seek(nextDescriptor - 0x8000, SeekOrigin.Begin); CDReader cd2 = new CDReader(new OffsetStreamDecorator(isoStream), true, true); vols = cd2.GetFiles("", "*.*", SearchOption.AllDirectories) .ToList() .Where(x => x.EndsWith(".VOL", StringComparison.OrdinalIgnoreCase)) .ToArray(); foreach (var volFile in vols) { yield return(cd2.OpenFile(volFile, FileMode.Open), Path.GetFileName(volFile)); } } } break; case FileType.UNKNOWN: case FileType.TOC22_VOL: case FileType.TOC22_ISO: case FileType.GTPSP_VOL: case FileType.GTPSP_ISO: default: throw new Exception("Invalid VOL type, can't get streams."); } }
static string FindGameId(string srcIso) { var regex = new Regex("(SCUS|SLUS|SLES|SCES|SCED|SLPS|SLPM|SCPS|SLED|SLPS|SIPS|ESPM|PBPX)[_-](\\d{3})\\.(\\d{2})", RegexOptions.IgnoreCase); var bootRegex = new Regex("BOOT\\s*=\\s*cdrom:\\\\?(?:.*?\\\\)?(.*?);1"); using (var stream = new FileStream(srcIso, FileMode.Open)) { var cdReader = new CDReader(stream, false, 2352); // Why doesn't a root file check not work? //foreach (var file in cdReader.GetFiles("\\")) //{ // var filename = file.Substring(1, file.LastIndexOf(";")); // var match = regex.Match(filename); // if (match.Success) // { // gameId = $"{match.Groups[1].Value}{match.Groups[2].Value}{match.Groups[3].Value}"; // break; // } //} var syscnfFound = false; foreach (var file in cdReader.GetFiles("\\")) { var filename = file.Substring(1, file.LastIndexOf(";") - 1); if (filename != "SYSTEM.CNF") { continue; } syscnfFound = true; using (var datastream = cdReader.OpenFile(file, FileMode.Open)) { datastream.Seek(24, SeekOrigin.Begin); var textReader = new StreamReader(datastream); var bootLine = textReader.ReadLine(); var bootmatch = bootRegex.Match(bootLine); if (!bootmatch.Success) { continue; } var match = regex.Match(bootmatch.Groups[1].Value); if (match.Success) { return($"{match.Groups[1].Value}{match.Groups[2].Value}{match.Groups[3].Value}"); } } } } return(null); }
public byte[] GetIcon(string ISOFile) { FileStream ISO = File.OpenRead(ISOFile); CDReader cdr = new CDReader(ISO, false); Stream ParamSfo = cdr.OpenFile(@"PSP_GAME\ICON0.PNG", FileMode.Open, FileAccess.Read); byte[] Icon0 = new byte[ParamSfo.Length]; ParamSfo.Read(Icon0, 0x00, (int)ParamSfo.Length); ISO.Close(); return(Icon0); }
static async Task Main(string[] args) { var s3 = new AmazonS3Client(); using var stream = new Cppl.Utilities.AWS.SeekableS3Stream(s3, BUCKET, KEY, 1 * 1024 * 1024, 4); using var iso = new CDReader(stream, true); using var file = iso.OpenFile(FILENAME, FileMode.Open, FileAccess.Read); using var reader = new StreamReader(file); var content = await reader.ReadToEndAsync(); await Console.Out.WriteLineAsync($"{stream.TotalRead:0,000} read {stream.TotalLoaded:0,000} loaded of {stream.Length:0,000} bytes"); }
/// <summary> /// Determine which kind of VOL(s) the ISO contains (if any). /// </summary> /// <returns>FileType</returns> private FileType GetISOType() { var fileType = FileType.UNKNOWN; using (FileStream isoStream = File.Open(_filePath, FileMode.Open)) { CDReader cd = new CDReader(isoStream, true, true); var vols = cd.GetFiles("", "*.*", SearchOption.AllDirectories) .ToList() .Where(x => x.EndsWith(".VOL", StringComparison.OrdinalIgnoreCase)) .ToArray(); if (vols.Length <= 0) { throw new ArgumentException("Invalid ISO file, no VOL inside."); } try { using (var fs = cd.OpenFile(vols.First(), FileMode.Open)) { var volType = GetVOLType(fs); switch (volType) { case FileType.TOC22_VOL: fileType = FileType.TOC22_ISO; break; case FileType.TOC31_VOL: fileType = FileType.TOC31_ISO; break; case FileType.GTPSP_VOL: fileType = FileType.GTPSP_ISO; break; case FileType.TOC22_ISO: case FileType.TOC31_ISO: case FileType.GTPSP_ISO: throw new Exception("Something went wrong when parsing the VOL file inside the ISO file."); case FileType.UNKNOWN: default: fileType = FileType.UNKNOWN; break; } } } catch (ArgumentException) { throw new ArgumentException("Invalid ISO file, no VOL inside."); } } return(fileType); }
public byte[] GetSfo(string ISOFile) { FileStream ISO = File.OpenRead(ISOFile); CDReader cdr = new CDReader(ISO, false); Stream ParamSfo = cdr.OpenFile(@"PSP_GAME\PARAM.SFO", FileMode.Open, FileAccess.Read); byte[] Sfo = new byte[ParamSfo.Length]; ParamSfo.Read(Sfo, 0x00, (int)ParamSfo.Length); ISO.Close(); return(Sfo); }
public static string GetTitleID(string ISOFile) { FileStream ISO = File.OpenRead(ISOFile); CDReader cdr = new CDReader(ISO, false); Stream ParamSfo = cdr.OpenFile(@"PSP_GAME\PARAM.SFO", FileMode.Open, FileAccess.Read); PARAM_SFO sfo = new PARAM_SFO(ParamSfo); string TitleID = sfo.GetValue("DISC_ID"); ISO.Close(); return(TitleID); }
static async Task Main(string[] args) { var s3 = new AmazonS3Client(); using var stream = new Cppl.Utilities.AWS.SeekableS3Stream(s3, BUCKET, KEY, 128 * 1024, 12); using var iso = new CDReader(stream, true); using var embedded = iso.OpenFile(ZIPNAME, FileMode.Open, FileAccess.Read); using var zip = new ZipArchive(embedded); using var file = zip.GetEntry(FILENAME).Open(); using var reader = new StreamReader(file); await reader.ReadLineAsync(); await Console.Out.WriteLineAsync($"{stream.TotalRead:0,000} read {stream.TotalLoaded:0,000} loaded of {stream.Length:0,000} bytes"); }
/// <summary> /// The save file. /// </summary> /// <param name="fileID"> /// The file id. /// </param> /// <param name="output"> /// The output. /// </param> public void SaveFile(int fileID, string output) { using (var fileStream = new FileStream(this.IsoPath, FileMode.Open)) { var reader = new CDReader(fileStream, true); using (var outFile = new FileStream(output, FileMode.Create, FileAccess.ReadWrite)) { using (Stream inFile = reader.OpenFile(this.Files[fileID].FileName, FileMode.Open)) { PumpStreams(inFile, outFile); } } } }
private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { using (FileStream isoStream = File.OpenRead(MainWindow.isoFiles[listBox.SelectedIndex].ToString())) { //use disk utils to read iso quickly CDReader cd = new CDReader(isoStream, true); //look for the spesific file Stream fileStream = cd.OpenFile(@"SYSTEM.CNF", FileMode.Open); // Use fileStream... TextReader tr = new StreamReader(fileStream); string fullstring = tr.ReadToEnd();//read string to end this will read all the info we need //mine for info string Is = @"\"; string Ie = ";"; //mine the start and end of the string int start = fullstring.ToString().IndexOf(Is) + Is.Length; int end = fullstring.ToString().IndexOf(Ie, start); if (end > start) { string PS2Id = fullstring.ToString().Substring(start, end - start); if (PS2Id != string.Empty) { lblTitleId.Content = PS2Id.Replace(".", "").Replace("_", ""); } else { System.Windows.Forms.MessageBox.Show("Could not load PS2 ID"); } } else { System.Windows.Forms.DialogResult dlr = System.Windows.Forms.MessageBox.Show("Could not load PS2 ID\n\n wpuld you like to submit an issue ?", "Error Reporting", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button2); if (dlr == System.Windows.Forms.DialogResult.Yes) { //load github issue page Process.Start(@"https://github.com/xXxTheDarkprogramerxXx/PS3Tools/issues"); } } } SoundClass.PlayPS4Sound(SoundClass.Sound.Navigation); } catch (Exception ex) { } }
public static bool isMini(string ISOFile) { FileStream ISO = File.OpenRead(ISOFile); CDReader cdr = new CDReader(ISO, false); Stream Icon0 = cdr.OpenFile(@"PSP_GAME\ICON0.PNG", FileMode.Open, FileAccess.Read); Bitmap bmp = new Bitmap(Icon0); bool isMini = (bmp.Width == 80 && bmp.Height == 80); bmp.Dispose(); ISO.Close(); return(isMini); }
public void listBox1_SelectedIndexChanged(object sender, EventArgs e) { //calc the size of the file long length = new System.IO.FileInfo(Form1.isoFiles[listBox1.SelectedIndex].ToString()).Length; //now make it human readable lblSize.Text = CalculateBytes(length);//human readble using (FileStream isoStream = File.OpenRead(Form1.isoFiles[listBox1.SelectedIndex].ToString())) { //use disk utils to read iso quickly CDReader cd = new CDReader(isoStream, true); //look for the spesific file Stream fileStream = cd.OpenFile(@"SYSTEM.CNF", FileMode.Open); // Use fileStream... TextReader tr = new StreamReader(fileStream); string fullstring = tr.ReadToEnd();//read string to end this will read all the info we need //mine for info string Is = @"\"; string Ie = ";"; //mine the start and end of the string int start = fullstring.ToString().IndexOf(Is) + Is.Length; int end = fullstring.ToString().IndexOf(Ie, start); if (end > start) { string PS2Id = fullstring.ToString().Substring(start, end - start); if (PS2Id != string.Empty) { lblTitleId.Text = "PS2 ID : " + PS2Id.Replace(".", ""); } else { MessageBox.Show("Could not load PS2 ID"); } } else { DialogResult dlr = MessageBox.Show("Could not load PS2 ID\n\n wpuld you like to submit an issue ?", "Error Reporting", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (dlr == DialogResult.Yes) { //load github issue page Process.Start(@"https://github.com/xXxTheDarkprogramerxXx/PS3Tools/issues"); } } } }
private void CloneCdDirectory(string dir, CDReader cdr, CDBuilder cdb) { foreach (string fileName in cdr.GetFiles(dir)) { if (fileName == "\\reactos\\unattend.inf") continue; var stream = cdr.OpenFile(fileName, FileMode.Open); cdb.AddFile(fileName.Remove(0, 1), stream); stream.Close(); } foreach (string dirName in cdr.GetDirectories(dir)) { CloneCdDirectory(dirName, cdr, cdb); } }
public async Task <object> Get(JsonDocument request, ILambdaContext context) { var s3 = new AmazonS3Client(); // easier than doing math on the timestamps in logs var timer = new Stopwatch(); timer.Start(); context.Logger.LogLine($"{timer.Elapsed}: Getting started."); using var stream = new Cppl.Utilities.AWS.SeekableS3Stream(s3, BUCKET, KEY, 12 * 1024 * 1024, 5); using var iso = new CDReader(stream, true); using var embedded = iso.OpenFile(ZIPNAME, FileMode.Open, FileAccess.Read); using var zip = new ZipArchive(embedded, ZipArchiveMode.Read); var entry = zip.GetEntry(FILENAME); using var file = entry.Open(); using var reader = new StreamReader(file); // how soon do we get the first line? var line = await reader.ReadLineAsync(); context.Logger.LogLine($"{timer.Elapsed}: First row received."); // read all of the remainline lines (it'll take a while...) ulong rows = 1; while ((line = await reader.ReadLineAsync()) != null) { ++rows; } context.Logger.LogLine($"{timer.Elapsed}: Done reading rows."); // the total amount read should be close to the total file size, but the amount loaded may be greated than // the file size if too few ranges are held in the MRU and end-up being loaded multiple times. context.Logger.LogLine($"{timer.Elapsed}: {stream.TotalRead:0,000} read {stream.TotalLoaded:0,000} loaded of {stream.Length:0,000} bytes"); timer.Stop(); return(new { IsoPath = $"s3://{BUCKET}/{KEY}", stream.TotalRead, stream.TotalLoaded, entry.Length, TotalRows = rows, Status = "ok" }); }
static public void ExtractIso(string isoPath, string targetDir) { using (FileStream isoStream = File.Open(isoPath, FileMode.Open, System.IO.FileAccess.Read)) { CDReader cd = new CDReader(isoStream, true); Stack <string> dirs = new Stack <string>(20); string root = @"\"; dirs.Push(root); while (dirs.Count > 0) { string currentDir = dirs.Pop(); Debug.WriteLine($"Scanning directory {currentDir}"); string tempPathDirectory = Pathy.Combine(targetDir, currentDir); Directory.CreateDirectory(tempPathDirectory); string[] subDirs = cd.GetDirectories(currentDir); try { string[] files = cd.GetFiles(currentDir); foreach (string file in files) { string normalizedFileName = file.Remove(file.Length - 2); string onIsoPath = Pathy.Combine(currentDir, file); string newPath = Pathy.Combine(targetDir, normalizedFileName); Debug.WriteLine($"Copying from {onIsoPath} to {newPath}"); using (var fileStream = File.Create(newPath)) { using (var gameFileStream = cd.OpenFile(file, FileMode.Open)) { gameFileStream.CopyTo(fileStream); } } } } catch (Exception err) { Debug.WriteLine(err); Debug.WriteLine($"Error ({err.Message}) in {currentDir}"); throw; } foreach (string str in subDirs) { dirs.Push(str); } } } }
private void ExtractISO_Directory(CDReader cd, string outputFolder, string cd_path) { var real_directory = string.Format("{0}/{1}", outputFolder, cd_path); if (!Directory.Exists(real_directory)) { Directory.CreateDirectory(real_directory); } var cd_directories = cd.GetDirectories(cd_path); foreach (var cd_directory in cd_directories) { ExtractISO_Directory(cd, outputFolder, cd_directory); } var cd_files = cd.GetFiles(cd_path); foreach (var cd_file in cd_files) { var fileStream = cd.OpenFile(cd_file, FileMode.Open); var attributes = cd.GetAttributes(cd_file); var real_file = string.Format("{0}/{1}", outputFolder, cd_file); Log($"extracting {cd_file} to {real_file}"); using (var writerStream = File.OpenWrite(real_file)) { var max_chunk = 1024; var buffer = new byte[max_chunk]; for (var b = 0; b < fileStream.Length; b += max_chunk) { var amount = (int)Math.Min(max_chunk, fileStream.Length - b); fileStream.Read(buffer, 0, amount); writerStream.Write(buffer, 0, amount); } } fileStream.Dispose(); } }
private XenServerPatchAlert GetAlertFromIsoFile(string fileName, out bool hasUpdateXml) { hasUpdateXml = false; if (!fileName.EndsWith(Branding.UpdateIso)) { return(null); } var xmlDoc = new XmlDocument(); try { using (var isoStream = File.OpenRead(fileName)) { var cd = new CDReader(isoStream, true); if (cd.Exists("Update.xml")) { using (var fileStream = cd.OpenFile("Update.xml", FileMode.Open)) { xmlDoc.Load(fileStream); hasUpdateXml = true; } } } } catch (Exception exception) { log.ErrorFormat("Exception while reading the update data from the iso file: {0}", exception.Message); } var elements = xmlDoc.GetElementsByTagName("update"); var update = elements.Count > 0 ? elements[0] : null; if (update == null || update.Attributes == null) { return(null); } var uuid = update.Attributes["uuid"]; return(uuid != null?Updates.FindPatchAlertByUuid(uuid.Value) : null); }