TurboPack / MustangpeakVirtualshellTools

Delphi and CBuilder Components to create Explorer type programs
Other
49 stars 24 forks source link

Introduce an option to avoid browsing content of ZIP files when populating the tree #9

Closed adrienreboisson closed 4 years ago

adrienreboisson commented 7 years ago

Hi !

I'm using the TVirtualExplorerTreeView component (dropped on the main form) and I experienced a strange situation where the application seemed "frozen" on startup - the app window did not appear with 100% CPU usage.

After some time spent in trying to reproduce the issue I discovered that the problem came from the way the tree handled ZIP files. On the user desktop there was a ZIP file with more than 100000 files, and as foNonFolder was assigned to the file FileObjects property (I need to allow selection of folders AND files) the component was trying to enumerate all its content to populate the tree. ZIP files are handled this way because Windows pretends this is a special kind of "folder" (SFGAO_FOLDER) - which is not entirely false.

I understand this behavior could be useful for some users, but it has some serious limitations :

According to MSDN :

"Some items can be flagged with both SFGAO_STREAM and SFGAO_FOLDER, such as a compressed file with a .zip file name extension. Some applications might include this flag when testing for items that are both files and containers"

So it's easy to avoid browsing these files by checking for items having both SFGAO_STREAM and SFGAO_FOLDER attributes set. This can be done by adding this kind of code in TCustomVirtualExplorerTree.ItemHasChildren() :

    if (NS.TestAttributesOf(SFGAO_STREAM, False)) and
       (NS.TestAttributesOf(SFGAO_FOLDER, False)) then
       Exit(False);

This works, but a more elegant solution would be to add a custom option into the component, for instance "toBrowseContainerFiles" in TreeOptions.VETFolderOptions, enabled by default. In this case, adding a such code in TCustomVirtualExplorerTree.ItemHasChildren would fix the problem :

    if not (toBrowseContainerFiles in TreeOptions.VETFolderOptions) then  
      if (NS.TestAttributesOf(SFGAO_STREAM, False)) and
         (NS.TestAttributesOf(SFGAO_FOLDER, False)) then
         Exit(False);

Do you think adding a such property to inhibit ZIP files content enumeration would be feasible ? I think that could help other users who don't want this kind of behavior.

Thanks,

Adrien

romankassebaum commented 7 years ago

Yes, that sounds great. :-)

Killea commented 7 years ago

How to not show the zip files? Sorry, I don't know how to modify the code. @adrienreboisson

I even don't need to show the zip files. It is really annoying.

pyscripter commented 4 years ago

Virtual Explore shows whatever Windows File Explorer shows. You could disable Windows 10 zip support.

Alternatively you you can implement the OnExpanding event to prevent Zip files from expanding.

Finally you can use the OnEnumFolder event to prevent folders or files showing.