Skip to content

Commit

Permalink
Add a version of Img.FileOpen that does not throw an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeeynamo committed Nov 16, 2019
1 parent 96c9804 commit 6b38069
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion OpenKh.Kh2/Img.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using Xe.IO;

Expand Down Expand Up @@ -43,6 +44,14 @@ public Img(Stream stream, Idx idx, bool loadAllIdx)

public Idx Idx { get; }

public bool FileOpen(string fileName, Action<Stream> callback)
{
bool result;
if (result = Idx.TryGetEntry(fileName, out var entry))
callback(FileOpen(entry));
return result;
}

public Stream FileOpen(string fileName)
{
if (Idx.TryGetEntry(fileName, out var entry))
Expand Down

0 comments on commit 6b38069

Please sign in to comment.