private static void AddFilesRecursive(ArcFile arcFile, ArcDirectoryNode root, List <ArcFileNode> files, bool mergeTrailingSlash) { if (mergeTrailingSlash) { var cleanedPath = root.Path.Trim('/'); // We don't display separate nodes for directories differing only by a trailing slash. // Try both options here in case one was removed. var rootNoSlash = arcFile.CreateNode(cleanedPath, ApplicationSettings.Instance.ArcRegion); if (rootNoSlash is ArcDirectoryNode rootDirectoryNoSlash) { AddChildrenRecursive(arcFile, files, rootDirectoryNoSlash, mergeTrailingSlash); } var rootWithSlash = arcFile.CreateNode(cleanedPath + '/', ApplicationSettings.Instance.ArcRegion); if (rootWithSlash is ArcDirectoryNode rootDirectoryWithSlash) { AddChildrenRecursive(arcFile, files, rootDirectoryWithSlash, mergeTrailingSlash); } } else { AddChildrenRecursive(arcFile, files, root, mergeTrailingSlash); } }
private static void AddChildNodes(ArcFile arcFile, string parentPath, Action <string, bool> extractStartCallBack, Action <string, double> extractReportProgressCallBack, Action <string> extractEndCallBack, List <FileNodeBase> files, bool mergeTrailingSlash) { var arcNode = arcFile.CreateNode(parentPath, ApplicationSettings.Instance.ArcRegion); if (arcNode is ArcDirectoryNode directoryNode) { // Keep track of visited names to avoid having duplicate nodes differing by a trailing slash. // Assume file names are also unique within a directory. var names = new HashSet <string>(); var folder = CreateFolder(arcFile, directoryNode, extractStartCallBack, extractReportProgressCallBack, extractEndCallBack, mergeTrailingSlash); foreach (var node in arcFile.GetChildren(directoryNode, ApplicationSettings.Instance.ArcRegion)) { var treeNode = CreateNode(arcFile, node, extractStartCallBack, extractReportProgressCallBack, extractEndCallBack, mergeTrailingSlash); // Only ignore duplicates if directories differing by a trailing slash should be merged. if (!mergeTrailingSlash || !names.Contains(treeNode.Name)) { files.Add(treeNode); names.Add(treeNode.Name); } } } }
public static FileNodeBase?CreateNodeFromPath(ArcFile arcFile, string absolutePath, Action <string, bool> taskStart, Action <string, double> reportProgress, Action <string> taskEnd, bool mergeTrailingSlash) { var arcNode = arcFile.CreateNode(absolutePath, ApplicationSettings.Instance.ArcRegion); if (arcNode == null) { return(null); } return(CreateNode(arcFile, arcNode, taskStart, reportProgress, taskEnd, mergeTrailingSlash)); }