I have a program that's watching for changes to certain files in a list of folders, including children (if a folder is watched, it will watch all children). I want to add the ability to exclude certain children from this process, but I'm not sure how best to process it or store the "Rules" for this. For example, here'a a tree I might watch:
Root
Folder1
SubFolder1
File1
File2
Folder2
File3
File4
I want to allow the user to select a folder (like "Root"), and it automatically selects all the children. If they uncheck a folder (like Folder1), I want to uncheck all the children of that one, but then if they check a child of a child (like File1), I want to check all its children (or, in this case, just watch File1, since it has no children).
I picture that I'll store this data as a list of nodes at which the user has taken some kind of action (either + or -), and walk down the folder list, one level at a time, until I get to a node where the user has taken a different action, then continue to walk into the folders/files further, checking at each step to see if the user has taken some action on that node in particular, and then propagating it to all the sub-nodes. If a new folder/file appears under a watched node, I want to start to watch it, but if it appears under an ignored node, I'll ignore it.
Do I just store each "actioned" folder/file, as well as the action (watch/ignore) that the user took, and then reconstruct the whole tree every time? Is there a more efficient way to do this that I'm not picturing?
I'm happy to clarify if my current explanation of how I picture this unclear. Also, I'm using .NET, but I'm more interested in the general process - I'll work out the implementation.