restore VFS after extraction if needed.

This commit is contained in:
morkt 2015-09-16 23:56:18 +04:00
parent ee14a418c0
commit 23b2970fa8

View File

@ -111,7 +111,7 @@ namespace GARbro.GUI
private MainWindow m_main; private MainWindow m_main;
private string m_arc_name; private string m_arc_name;
private ArchiveFileSystem m_fs; private ArchiveFileSystem m_fs;
private readonly bool m_should_dispose; private readonly bool m_should_ascend;
private bool m_skip_images = false; private bool m_skip_images = false;
private bool m_skip_script = false; private bool m_skip_script = false;
private bool m_skip_audio = false; private bool m_skip_audio = false;
@ -127,21 +127,18 @@ namespace GARbro.GUI
public GarExtract (MainWindow parent, string source) public GarExtract (MainWindow parent, string source)
{ {
m_main = parent;
m_arc_name = Path.GetFileName (source); m_arc_name = Path.GetFileName (source);
FormatCatalog.Instance.LastError = null; try
var arc = ArcFile.TryOpen (source);
if (null == arc)
{ {
string error_message; VFS.ChDir (source);
if (FormatCatalog.Instance.LastError != null) m_should_ascend = true;
error_message = FormatCatalog.Instance.LastError.Message;
else
error_message = garStrings.MsgUnknownFormat;
throw new OperationCanceledException (string.Format ("{1}: {0}", error_message, m_arc_name));
} }
m_fs = arc.CreateFileSystem(); catch (Exception X)
m_should_dispose = true; {
throw new OperationCanceledException (string.Format ("{1}: {0}", X.Message, m_arc_name));
}
m_fs = VFS.Top as ArchiveFileSystem;
m_main = parent;
} }
public GarExtract (MainWindow parent, string source, ArchiveFileSystem fs) public GarExtract (MainWindow parent, string source, ArchiveFileSystem fs)
@ -151,7 +148,7 @@ namespace GARbro.GUI
m_fs = fs; m_fs = fs;
m_main = parent; m_main = parent;
m_arc_name = Path.GetFileName (source); m_arc_name = Path.GetFileName (source);
m_should_dispose = false; m_should_ascend = false;
} }
private void PrepareDestination (string destination) private void PrepareDestination (string destination)
@ -443,8 +440,10 @@ namespace GARbro.GUI
{ {
if (!disposed) if (!disposed)
{ {
if (m_should_dispose) if (m_should_ascend)
m_fs.Dispose(); {
VFS.ChDir ("..");
}
disposed = true; disposed = true;
} }
GC.SuppressFinalize (this); GC.SuppressFinalize (this);