microsoft / winfile

Original Windows File Manager (winfile) with enhancements
MIT License
6.86k stars 709 forks source link

Symlink Icons are not shown after (un)compress #315

Closed schinagl closed 2 years ago

schinagl commented 2 years ago

Problem

In the aftermath of #308 I stumbled about one detail we missed: After (un)compress on a symbolic link the symlink icon is not shown anymore.

How to test

Download ln.exe from https://schinagl.priv.at/nt/ln/ln64.zip and place it in the same directory as the below .bat file. Start TestCopyReparsePoint.bat from an administrative command prompt in your e.g. temp directory.

It builds a structure like

├───1
└───sl
    ├───iLib
    │   ├───inc
    │   └───src
    ├───iLib_symlink
    │   ├───inc
    │   └───src
    └───zzz

Select sl/iLib_symlink and choose from the menu File/(Un)Compress. The symlink icon of sl/iLib_symlink is shown properly contrary to the original.

Comments on the code

There are two locations in the source where the attributes are fetched directly via GetFileAttributes() and thus bypass WFFind{First|Next} extended in #297

  1. treectl.c/InsertDirectory()
  2. wffile.c/RedrawAllTreeWindows()

The topic 1. was handled in #308 as a byproduct, but 2. is addressed in this PR. Anyhow, the fix is simple and introduces a helper function SetNodeAttribs(), which is called from 1) and 2)

craigwims commented 2 years ago

Glad you found this. It is one of the perils of working on an old code base with some redundancy "built" in -- e.g. #define ATTR_DIR FILE_ATTRIBUTE_DIRECTORY.