Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
492 additions
and
525 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,29 @@ | ||
using LibHac; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
|
||
namespace SwitchExplorer | ||
{ | ||
internal class IO | ||
{ | ||
// Source: https://stackoverflow.com/a/19332770 | ||
public static void PopulateTreeView(TreeView treeView, string[] paths, char pathSeparator) | ||
// Thanks to Alex Barney for providing this code! | ||
public static void PopulateTreeView(TreeNodeCollection nodes, RomfsDir root) | ||
{ | ||
TreeNode lastNode = null; | ||
string subPathAgg; | ||
foreach (string path in paths) | ||
RomfsFile fileNode = root.FirstFile; | ||
|
||
while (fileNode != null) | ||
{ | ||
nodes.Add(fileNode.FullPath, fileNode.Name); | ||
fileNode = fileNode.NextSibling; | ||
} | ||
|
||
RomfsDir dirNode = root.FirstChild; | ||
|
||
while (dirNode != null) | ||
{ | ||
subPathAgg = string.Empty; | ||
foreach (string subPath in path.Split(pathSeparator)) | ||
{ | ||
subPathAgg += subPath + pathSeparator; | ||
TreeNode[] nodes = treeView.Nodes.Find(subPathAgg, true); | ||
if (nodes.Length == 0) | ||
if (lastNode == null) | ||
lastNode = treeView.Nodes.Add(subPathAgg, subPath); | ||
else | ||
lastNode = lastNode.Nodes.Add(subPathAgg, subPath); | ||
else | ||
lastNode = nodes[0]; | ||
} | ||
lastNode = null; | ||
TreeNode newNode = nodes.Add(dirNode.FullPath, dirNode.Name); | ||
PopulateTreeView(newNode.Nodes, dirNode); | ||
dirNode = dirNode.NextSibling; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.