Closed Sewer56 closed 11 months ago
I already started some work on this when I was experimenting on enhanced-filetree
branch.
Here are some notes I took down for myself
❌ means TODO
⚡ means 'requires specialized implementations' (non-traitable)
✅ means already implemented.
- ✅ GetSiblings | IHaveChildrenWithKey, IHaveParent
- ✅ ReconstructPath | IHaveParent, IHavePathSegment
- ✅ GetAllDescendantsAsDictionary | IHaveChildrenWithKey
- ✅ FindNode | IHaveChildrenWithKey, IHavePathSegment, IHaveFullPath
- ✅ FindSubPath | IHaveChildrenWithKey, IHavePathSegment
- ❌ AddChildren | IHaveParent, IHaveDepth, IHaveChildren
- ❌ AddChild | IHaveParent, IHaveDepth, IHaveChildren
- ⚡ CreateTree(IEnumerable<KeyValuePair<TPath, TValue>> files)
- ❓ Deconstruct
- ✅ GetAllChildren a.k.a. GetAllNodes | IHaveChildren, IHaveChildrenWithKey
- ✅ CountFiles | IHaveAFileOrDirectory
- ✅ CountDirectories | IHaveAFileOrDirectory
- ✅ CountDescendants
In any case, this is being delayed till next milestone.
Edit: This is outdated, check the wiki in enhanced-filetree
branch for current status
Improvement
Currently
We have only one
FileTree
implementation, which is tailored specifically to use in NexusMods.App's LoadoutSynchronizer and FOMOD installer.We want
When working on the Advanced Installer Functionality, a need to display a file tree of existing game folders arose.
Specifically, displaying existing files in Game directory and Saves directory.
This involves reading the directory structure of the game, and displaying it into UI.
Originally I considered:
Adding an method into
GameInstallation
for building a file tree.Adding an extension method to this library that emits a FileTree from
AbsolutePath
.Therefore while it's technically not blocking; it's very much blocking in the sense that long term, this will lead to more work.
Design
Here is an example of how you can write trees using traits:
To use it, simply create a tree type and implement the interface
And you can now call methods provided by these interfaces:
Note that this approach is zero overhead. i.e. It's as good as if written directly into class.