mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 13:45:34 +08:00
(ExtractImage): use ArcFile.CreateFile() to create output file.
This commit is contained in:
parent
474548bae5
commit
9d218a4130
@ -160,6 +160,14 @@ namespace GARbro.GUI
|
||||
{
|
||||
using (var file = arc.OpenEntry (entry))
|
||||
{
|
||||
string source_ext = Path.GetExtension (entry.Name).TrimStart ('.').ToLower();
|
||||
if (target_format.Extensions.Any (ext => ext == source_ext))
|
||||
{
|
||||
// source extension matches target image format, copy file as is
|
||||
using (var output = arc.CreateFile (entry))
|
||||
file.CopyTo (output);
|
||||
return;
|
||||
}
|
||||
ImageData image = ImageFormat.Read (file);
|
||||
if (null == image)
|
||||
throw new InvalidFormatException (string.Format ("{1}: {0}", guiStrings.MsgUnableInterpret, entry.Name));
|
||||
@ -167,8 +175,8 @@ namespace GARbro.GUI
|
||||
string outdir = Path.GetDirectoryName (entry.Name);
|
||||
string outname = Path.GetFileNameWithoutExtension (entry.Name)+'.'+target_ext;
|
||||
outname = Path.Combine (outdir, outname);
|
||||
Trace.WriteLine (string.Format ("{0} => {1}", entry.Name, outname), "ExtractFileFromArchive");
|
||||
using (var outfile = File.Create (outname))
|
||||
Trace.WriteLine (string.Format ("{0} => {1}", entry.Name, outname), "ExtractImage");
|
||||
using (var outfile = arc.CreateFile (new Entry { Name = outname }))
|
||||
{
|
||||
target_format.Write (outfile, image);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user