What is the best way to go about parsing all of this and adding it to a tree-view control while maintaining the folder structure? The tree-view should look like this:
I want to preserve the folder structure in a tree-view control. In other words I want to add Folder1 as a root node, and Subfolder1 and Subfolder2 as children and so on.
I know how to use the tree control but preserving the folder structure is my problem. It should look like this in the tree-view control:
For the record I am only adding folders to the tree-view and not files. The only solution I could come up with was to split each path into individual folder names and for each folder search the entire tree control to see if it's been added and add it if not. This won't work though as it takes way too long.
Ahh, well, in that case, you are parsing the folder entries. I am assuming they are strings, with that in mind, you should be able to use str.substr read up here:
I already know about strings. The problem i'm having is adding folder names to the tree-view while preserving the folder structure of the zip file and doing it in a reasonable amount of time.
I know how to recursively search the tree-view but doing this for each and every folder takes too long(or maybe this is the correct way but my code is bad?). I thought about taking advantage of the fact that pathnames are always listed in order where the root folder is followed by subfolders(as I showed in my second post_) but I don't know...
I am not understanding your problem, if you want to put them in a list view, use a for or while loop and substr I linked above. In the loop, split the text with substr, then assign them separate variables, and cout the variables in the tree view or whatever you want to do with them, and where is the HTREEITEM AddItem function from? The Util you linked above?
The problem is maintaining the folder structure when adding each folder to the tree-view. The difficulty is getting the handle to the parent HTREEITEM. As you see there are a lot of repetitions in the path list I get from ziputil so I cant simply search through the entire tree for every folder in every path to find the right parent.
But anyway I started using std::map to associate full path names with HTREEITEM handles and it works wonderfully.