mirror of
https://github.com/KillzXGaming/Switch-Toolbox
synced 2024-11-10 15:14:55 +00:00
Support loading multiple IArchive and node types from a single format within an archive file
This commit is contained in:
parent
2df6d35d17
commit
25bc66e505
11 changed files with 19 additions and 19 deletions
|
@ -111,6 +111,8 @@ namespace FirstPlugin
|
|||
|
||||
uint Count = reader.ReadUInt32();
|
||||
|
||||
Console.WriteLine($"Count {Count}");
|
||||
|
||||
uint[] Offsets = new uint[Count];
|
||||
uint[] Sizes = new uint[Count];
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ using LibHac;
|
|||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class IStorage : IArchiveFile, IFileFormat, IFileDisposeAfterLoad
|
||||
public class IStorage : IArchiveFile, IFileFormat, ILeaveOpenOnLoad
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Rom;
|
||||
|
||||
|
@ -34,8 +34,6 @@ namespace FirstPlugin
|
|||
public bool CanReplaceFiles { get; set; }
|
||||
public bool CanDeleteFiles { get; set; }
|
||||
|
||||
public bool CanDispose { get { return false; } }
|
||||
|
||||
public List<NSP.FileEntry> files = new List<NSP.FileEntry>();
|
||||
public IEnumerable<ArchiveFileInfo> Files => files;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ using LibHac.IO;
|
|||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class NCA : IFileFormat, IArchiveFile, IFileDisposeAfterLoad
|
||||
public class NCA : IFileFormat, IArchiveFile, ILeaveOpenOnLoad
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Rom;
|
||||
|
||||
|
@ -34,8 +34,6 @@ namespace FirstPlugin
|
|||
public bool CanReplaceFiles { get; set; }
|
||||
public bool CanDeleteFiles { get; set; }
|
||||
|
||||
public bool CanDispose { get { return false; } }
|
||||
|
||||
public List<NSP.FileEntry> files = new List<NSP.FileEntry>();
|
||||
public IEnumerable<ArchiveFileInfo> Files => files;
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ using System.ComponentModel;
|
|||
namespace FirstPlugin
|
||||
{
|
||||
|
||||
public class NSP : IArchiveFile, IFileFormat, IFileDisposeAfterLoad
|
||||
public class NSP : IArchiveFile, IFileFormat, ILeaveOpenOnLoad
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Rom;
|
||||
|
||||
|
@ -39,8 +39,6 @@ namespace FirstPlugin
|
|||
Nca Control { get; set; }
|
||||
RomfsNodeWrapper romfsWrapper;
|
||||
|
||||
public bool CanDispose { get { return false; } }
|
||||
|
||||
public bool CanAddFiles { get; set; }
|
||||
public bool CanRenameFiles { get; set; }
|
||||
public bool CanReplaceFiles { get; set; }
|
||||
|
|
|
@ -7,7 +7,7 @@ using Toolbox.Library;
|
|||
|
||||
namespace FirstPlugin
|
||||
{
|
||||
public class XCI : IFileFormat, IFileDisposeAfterLoad
|
||||
public class XCI : IFileFormat, ILeaveOpenOnLoad
|
||||
{
|
||||
public FileType FileType { get; set; } = FileType.Rom;
|
||||
|
||||
|
@ -32,8 +32,6 @@ namespace FirstPlugin
|
|||
return Utils.HasExtension(FileName, ".xci");
|
||||
}
|
||||
|
||||
public bool CanDispose { get { return false; } }
|
||||
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -361,8 +361,8 @@ namespace Toolbox.Library.IO
|
|||
}
|
||||
//After file has been loaded and read, we'll dispose unless left open
|
||||
|
||||
if (fileFormat is IFileDisposeAfterLoad) {
|
||||
LeaveStreamOpen = !((IFileDisposeAfterLoad)fileFormat).CanDispose;
|
||||
if (fileFormat is ILeaveOpenOnLoad) {
|
||||
LeaveStreamOpen = true;
|
||||
}
|
||||
|
||||
if (!LeaveStreamOpen)
|
||||
|
|
|
@ -830,14 +830,21 @@ namespace Toolbox.Library
|
|||
{
|
||||
OpenFormDialog(file);
|
||||
}
|
||||
else if (file is TreeNode)
|
||||
ReplaceNode(this.Parent, treeview, this, (TreeNode)file, RootNode);
|
||||
else if (file is IArchiveFile)
|
||||
{
|
||||
var FileRoot = new ArchiveRootNodeWrapper(file.FileName, (IArchiveFile)file);
|
||||
FileRoot.FillTreeNodes();
|
||||
|
||||
if (file is TreeNode) //It can still be both, so add all it's nodes
|
||||
{
|
||||
foreach (TreeNode n in ((TreeNode)file).Nodes)
|
||||
FileRoot.Nodes.Add(n);
|
||||
}
|
||||
|
||||
ReplaceNode(this.Parent, treeview, this, FileRoot, RootNode);
|
||||
}
|
||||
else if (file is TreeNode)
|
||||
ReplaceNode(this.Parent, treeview, this, (TreeNode)file, RootNode);
|
||||
}
|
||||
|
||||
private void OpenFormDialog(IFileFormat fileFormat)
|
||||
|
|
|
@ -7,8 +7,7 @@ using System.Threading.Tasks;
|
|||
namespace Toolbox.Library
|
||||
{
|
||||
//Check if the opened file stream should be disposed after loading
|
||||
public interface IFileDisposeAfterLoad
|
||||
public interface ILeaveOpenOnLoad
|
||||
{
|
||||
bool CanDispose { get; }
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
|
@ -245,7 +245,7 @@
|
|||
</Compile>
|
||||
<Compile Include="Generics\Texture\ImageParameters.cs" />
|
||||
<Compile Include="Generics\Texture\STTextureFolder.cs" />
|
||||
<Compile Include="Interfaces\ICanDispose.cs" />
|
||||
<Compile Include="Interfaces\ILeaveOpenOnLoad.cs" />
|
||||
<Compile Include="Interfaces\ICloneableNode.cs" />
|
||||
<Compile Include="Interfaces\IMeshContainer.cs" />
|
||||
<Compile Include="Interfaces\ITextureContainer.cs" />
|
||||
|
|
Loading…
Reference in a new issue