From 5bce17785ac3d0305b9fa8287901ae965d0d3b63 Mon Sep 17 00:00:00 2001 From: dexyfex Date: Tue, 27 Feb 2018 19:59:14 +1100 Subject: [PATCH] Fix for RPF Explorer not showing empty folders --- ExploreForm.cs | 61 +++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/ExploreForm.cs b/ExploreForm.cs index 53eefb4..4d81e60 100644 --- a/ExploreForm.cs +++ b/ExploreForm.cs @@ -557,7 +557,7 @@ namespace CodeWalker string fullPath = GTAFolder.GetCurrentGTAFolderWithTrailingSlash(); - string[] allfiles = Directory.GetFiles(GTAFolder.CurrentGTAFolder, "*", SearchOption.AllDirectories); + string[] allpaths = Directory.GetFileSystemEntries(GTAFolder.CurrentGTAFolder, "*", SearchOption.AllDirectories); Dictionary nodes = new Dictionary(); @@ -569,16 +569,18 @@ namespace CodeWalker UpdateStatus("Scanning..."); - foreach (var filepath in allfiles) + foreach (var path in allpaths) { - var relpath = filepath.Replace(fullPath, ""); - var filepathl = filepath.ToLowerInvariant(); + var relpath = path.Replace(fullPath, ""); + var filepathl = path.ToLowerInvariant(); + + var isFile = File.Exists(path); //could be a folder UpdateStatus("Scanning " + relpath + "..."); MainTreeFolder parentnode = null, prevnode = null, node = null; var prevnodepath = ""; - var idx = relpath.LastIndexOf('\\'); + var idx = isFile ? relpath.LastIndexOf('\\') : relpath.Length; while (idx > 0) //create the folder tree nodes and build up the hierarchy { var parentpath = relpath.Substring(0, idx); @@ -608,34 +610,37 @@ namespace CodeWalker } } - if (filepathl.EndsWith(".rpf")) //add RPF nodes + if (isFile) { - RpfFile rpf = new RpfFile(filepath, relpath); - - rpf.ScanStructure(UpdateStatus, UpdateErrorLog); - - node = CreateRpfTreeFolder(rpf, relpath, filepath); - - RecurseMainTreeViewRPF(node, allRpfs); - - if (parentnode != null) + if (filepathl.EndsWith(".rpf")) //add RPF nodes { - parentnode.AddChild(node); + RpfFile rpf = new RpfFile(path, relpath); + + rpf.ScanStructure(UpdateStatus, UpdateErrorLog); + + node = CreateRpfTreeFolder(rpf, relpath, path); + + RecurseMainTreeViewRPF(node, allRpfs); + + if (parentnode != null) + { + parentnode.AddChild(node); + } + else + { + root.AddChild(node); + } } else { - root.AddChild(node); - } - } - else - { - if (parentnode != null) - { - parentnode.AddFile(filepath); - } - else - { - root.AddFile(filepath); + if (parentnode != null) + { + parentnode.AddFile(path); + } + else + { + root.AddFile(path); + } } } }