Skip to content

Commit

Permalink
Catch exceptions on Disc meta XML file reading
Browse files Browse the repository at this point in the history
addresses #29
  • Loading branch information
UniqProject committed Jan 21, 2023
1 parent 3dfa4a7 commit 61cc6c5
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions BDInfo/BDROM/BDROM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,17 +410,27 @@ public BDROM(

private void ReadDiscTitle(StreamReader fileStream)
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(fileStream);
var xNsMgr = new XmlNamespaceManager(xDoc.NameTable);
xNsMgr.AddNamespace("di", "urn:BDA:bdmv;discinfo");
var xNode = xDoc.DocumentElement?.SelectSingleNode("di:discinfo/di:title/di:name", xNsMgr);
DiscTitle = xNode?.InnerText;

if (!string.IsNullOrEmpty(DiscTitle) && DiscTitle.ToLowerInvariant() == "blu-ray")
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(fileStream);
var xNsMgr = new XmlNamespaceManager(xDoc.NameTable);
xNsMgr.AddNamespace("di", "urn:BDA:bdmv;discinfo");
var xNode = xDoc.DocumentElement?.SelectSingleNode("di:discinfo/di:title/di:name", xNsMgr);
DiscTitle = xNode?.InnerText;

if (!string.IsNullOrEmpty(DiscTitle) && DiscTitle.ToLowerInvariant() == "blu-ray")
DiscTitle = null;
}
catch (Exception)
{
DiscTitle = null;

fileStream.Close();
}
finally
{
fileStream.Close();
}

}

public void Scan()
Expand Down

0 comments on commit 61cc6c5

Please sign in to comment.