migration to IBinaryStream interface.

This commit is contained in:
morkt
2016-10-15 09:34:46 +04:00
parent 0b96ef8f77
commit 503b734645
16 changed files with 264 additions and 332 deletions

View File

@@ -187,7 +187,7 @@ namespace GARbro.GUI
void ConvertAudio (string filename)
{
using (var file = File.OpenRead (filename))
using (var file = BinaryStream.FromFile (filename))
using (var input = AudioFormat.Read (file))
{
if (null == input)
@@ -223,9 +223,9 @@ namespace GARbro.GUI
string target_name = Path.GetFileName (filename);
string target_ext = m_image_format.Extensions.FirstOrDefault();
target_name = Path.ChangeExtension (target_name, target_ext);
using (var file = File.OpenRead (filename))
using (var file = BinaryStream.FromFile (filename))
{
var src_format = ImageFormat.FindFormat (file, filename);
var src_format = ImageFormat.FindFormat (file);
if (null == src_format)
return;
if (src_format.Item1 == m_image_format && m_image_format.Extensions.Any (ext => ext == source_ext))

View File

@@ -306,9 +306,9 @@ namespace GARbro.GUI
void ExtractImage (ArcFile arc, Entry entry, ImageFormat target_format)
{
using (var file = arc.OpenSeekableEntry (entry))
using (var file = arc.OpenBinaryEntry (entry))
{
var src_format = ImageFormat.FindFormat (file, entry.Name);
var src_format = ImageFormat.FindFormat (file);
if (null == src_format)
throw new InvalidFormatException (string.Format ("{1}: {0}", guiStrings.MsgUnableInterpretImage, entry.Name));
file.Position = 0;
@@ -318,7 +318,7 @@ namespace GARbro.GUI
{
// source format is the same as a target, copy file as is
using (var output = ArchiveFormat.CreateFile (outname))
file.CopyTo (output);
file.AsStream.CopyTo (output);
return;
}
ImageData image = src_format.Item1.Read (file, src_format.Item2);
@@ -364,7 +364,7 @@ namespace GARbro.GUI
static void ExtractAudio (ArcFile arc, Entry entry)
{
using (var file = arc.OpenEntry (entry))
using (var file = arc.OpenBinaryEntry (entry))
using (var sound = AudioFormat.Read (file))
{
if (null == sound)

View File

@@ -188,17 +188,12 @@ namespace GARbro.GUI
}
}
Stream OpenPreviewStream (PreviewFile preview)
{
return VFS.OpenSeekableStream (preview.Entry);
}
void LoadPreviewText (PreviewFile preview)
{
Stream file = null;
try
{
file = OpenPreviewStream (preview);
file = VFS.OpenBinaryStream (preview.Entry).AsStream;
if (!TextView.IsTextFile (file))
{
ResetPreviewPane();
@@ -230,9 +225,9 @@ namespace GARbro.GUI
{
try
{
using (var file = OpenPreviewStream (preview))
using (var file = VFS.OpenBinaryStream (preview.Entry))
{
var data = ImageFormat.Read (preview.Name, file);
var data = ImageFormat.Read (file);
if (null != data)
SetPreviewImage (preview, data.Bitmap);
else

View File

@@ -924,7 +924,7 @@ namespace GARbro.GUI
try
{
SetBusyState();
using (var input = VFS.OpenStream (entry))
using (var input = VFS.OpenBinaryStream (entry))
{
FormatCatalog.Instance.LastError = null;
sound = AudioFormat.Read (input);