Adjustments for limiting the size
This commit is contained in:
parent
b8aad096ff
commit
99883c9a5b
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -55,9 +55,6 @@ namespace FirstPlugin
|
||||
byte[] DecompressedBlock;
|
||||
SDFTOC_ID endId;
|
||||
|
||||
//Temp but just for now as this is expeirmental. Need to optmize tree loading
|
||||
private readonly int MAX_FILE_DISPLAY = 4000;
|
||||
|
||||
//Thanks to https://github.com/GoldFarmer/rouge_sdf/blob/master/main.cpp for docs/structs
|
||||
public void Load(System.IO.Stream stream)
|
||||
{
|
||||
@ -110,8 +107,7 @@ namespace FirstPlugin
|
||||
MessageBox.Show("Note! Support for this format is experimental. The tool will only load < 4000 files atm due to slow loading");
|
||||
|
||||
for (int i = 0; i < FileEntries.Count; i++)
|
||||
if (i < MAX_FILE_DISPLAY)
|
||||
files.Add(FileEntries[i]);
|
||||
files.Add(FileEntries[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -32,69 +32,63 @@ namespace Switch_Toolbox.Library.Forms
|
||||
}
|
||||
|
||||
//The process takes awhile atm so limit splitting if there's a high amount
|
||||
private readonly int MAX_FILE_PATH_SPLIT = 5000;
|
||||
private readonly int MAX_FILE_LOAD = 5000;
|
||||
|
||||
void FillTreeNodes(TreeNode root, IArchiveFile archiveFile)
|
||||
{
|
||||
var rootText = root.Text;
|
||||
var rootTextLength = rootText.Length;
|
||||
var nodeFiles = archiveFile.Files;
|
||||
if (nodeFiles.Count() > MAX_FILE_PATH_SPLIT)
|
||||
{
|
||||
foreach (var node in nodeFiles)
|
||||
{
|
||||
ArchiveFileWrapper wrapperFile = new ArchiveFileWrapper(node.FileName, node, archiveFile);
|
||||
root.Nodes.Add(wrapperFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var node in nodeFiles)
|
||||
{
|
||||
string nodeString = node.FileName;
|
||||
|
||||
var roots = nodeString.Split(new char[] { '/' },
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
int I = 0;
|
||||
foreach (var node in nodeFiles)
|
||||
{
|
||||
if (I++ > MAX_FILE_LOAD)
|
||||
break;
|
||||
|
||||
// The initial parent is the root node
|
||||
var parentNode = root;
|
||||
var sb = new StringBuilder(rootText, nodeString.Length + rootTextLength);
|
||||
for (int rootIndex = 0; rootIndex < roots.Length; rootIndex++)
|
||||
string nodeString = node.FileName;
|
||||
|
||||
var roots = nodeString.Split(new char[] { '/' },
|
||||
StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
// The initial parent is the root node
|
||||
var parentNode = root;
|
||||
var sb = new StringBuilder(rootText, nodeString.Length + rootTextLength);
|
||||
for (int rootIndex = 0; rootIndex < roots.Length; rootIndex++)
|
||||
{
|
||||
// Build the node name
|
||||
var parentName = roots[rootIndex];
|
||||
sb.Append("/");
|
||||
sb.Append(parentName);
|
||||
var nodeName = sb.ToString();
|
||||
|
||||
// Search for the node
|
||||
var index = parentNode.Nodes.IndexOfKey(nodeName);
|
||||
if (index == -1)
|
||||
{
|
||||
// Build the node name
|
||||
var parentName = roots[rootIndex];
|
||||
sb.Append("/");
|
||||
sb.Append(parentName);
|
||||
var nodeName = sb.ToString();
|
||||
// Node was not found, add it
|
||||
|
||||
// Search for the node
|
||||
var index = parentNode.Nodes.IndexOfKey(nodeName);
|
||||
if (index == -1)
|
||||
var folder = new ArchiveFolderNodeWrapper(parentName, archiveFile);
|
||||
|
||||
if (rootIndex == roots.Length - 1)
|
||||
{
|
||||
// Node was not found, add it
|
||||
|
||||
var folder = new ArchiveFolderNodeWrapper(parentName, archiveFile);
|
||||
|
||||
if (rootIndex == roots.Length - 1)
|
||||
{
|
||||
ArchiveFileWrapper wrapperFile = new ArchiveFileWrapper(parentName, node, archiveFile);
|
||||
wrapperFile.Name = nodeName;
|
||||
parentNode.Nodes.Add(wrapperFile);
|
||||
parentNode = wrapperFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
folder.Name = nodeName;
|
||||
parentNode.Nodes.Add(folder);
|
||||
parentNode = folder;
|
||||
}
|
||||
ArchiveFileWrapper wrapperFile = new ArchiveFileWrapper(parentName, node, archiveFile);
|
||||
wrapperFile.Name = nodeName;
|
||||
parentNode.Nodes.Add(wrapperFile);
|
||||
parentNode = wrapperFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Node was found, set that as parent and continue
|
||||
parentNode = parentNode.Nodes[index];
|
||||
folder.Name = nodeName;
|
||||
parentNode.Nodes.Add(folder);
|
||||
parentNode = folder;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Node was found, set that as parent and continue
|
||||
parentNode = parentNode.Nodes[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user