mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-26 14:30:26 +00:00
Adjustments for loading archive files
This commit is contained in:
parent
1ded215e52
commit
74f69eb1d8
1 changed files with 24 additions and 7 deletions
|
@ -79,7 +79,9 @@ namespace Toolbox.Library
|
|||
[Browsable(false)]
|
||||
public virtual IFileFormat OpenFile()
|
||||
{
|
||||
if (FileFormat != null)
|
||||
if (FileFormat != null &&
|
||||
FileFormat.IFileInfo != null &&
|
||||
FileFormat.IFileInfo.ArchiveParent != null)
|
||||
return FileFormat;
|
||||
|
||||
if (FileDataStream != null)
|
||||
|
@ -174,6 +176,27 @@ namespace Toolbox.Library
|
|||
}
|
||||
}
|
||||
|
||||
public static void SaveFileFormat(ArchiveFileInfo archiveFile, IFileFormat fileFormat)
|
||||
{
|
||||
if (fileFormat != null && fileFormat.CanSave)
|
||||
{
|
||||
if (archiveFile.FileDataStream != null)
|
||||
{
|
||||
var mem = new System.IO.MemoryStream();
|
||||
fileFormat.Save(mem);
|
||||
archiveFile.FileDataStream = mem;
|
||||
//Reload file data
|
||||
fileFormat.Load(archiveFile.FileDataStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
var mem = new System.IO.MemoryStream();
|
||||
fileFormat.Save(mem);
|
||||
archiveFile.FileData = STLibraryCompression.CompressFile(mem.ToArray(), fileFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveFileFormat()
|
||||
{
|
||||
if (FileFormat != null && FileFormat.CanSave)
|
||||
|
@ -894,9 +917,6 @@ namespace Toolbox.Library
|
|||
OpenFormDialog(file);
|
||||
else if (file is IArchiveFile)
|
||||
{
|
||||
if (ArchiveFileInfo.FileFormat != null)
|
||||
ArchiveFileInfo.FileFormat.Unload();
|
||||
|
||||
var FileRoot = new ArchiveRootNodeWrapper(file.FileName, (IArchiveFile)file);
|
||||
FileRoot.FillTreeNodes();
|
||||
|
||||
|
@ -910,9 +930,6 @@ namespace Toolbox.Library
|
|||
}
|
||||
else if (file is TreeNode)
|
||||
{
|
||||
if (ArchiveFileInfo.FileFormat != null)
|
||||
ArchiveFileInfo.FileFormat.Unload();
|
||||
|
||||
ReplaceNode(this.Parent, treeview, this, (TreeNode)file, RootNode);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue