Open malxau-msft opened 6 months ago
A few things
dwFilterAttribs could be declared after wfcomman.c:309 and it is still C89
- I suggest to extend the case statement in wfcomman.c:331 instead of adding an extra if statement in wfcomman.c:295.
Thanks. I think the reason I couldn't do this is because there's already an FSC_ATTRIBUTES case statement which is shared with six other operations. The logic could be moved into the case statement, but I'd still need either an extra if to ensure the new code only runs for FSC_ATTRIBUTES, duplicate the code that currently runs in FSC_ATTRIBUTES, or use goto. None of them seemed to fit well.
Then move it in to case FSC_ATTRIBUTES: and use the if.
Someone who reverse engineers this code is happy to find all stuff related to FSC_ATTRIBUTES in one place and not spread around.
Furthermore you have not commented on the 'dwFilterAttribs could be declared after wfcomman.c:309'.
Respecting the principle of locality is a commonly accepted pattern and the above would still be C89 if you want to go to your nmake based vs2005 build for w2k
This is a fairly isolated approach to update the tree in response to changes to hidden/system attributes for directories. (I'm not sure if it's the best approach, but sending it out for comment anyway.)
Scenarios this change addresses
Scenarios not addressed by this change
Next steps
As mentioned above, it's not feasible to monitor changes for the entire drive and refresh, which is implied by using
FindFirstChangeNotification
. Monitoring for external changes requires something more efficient so winfile can quickly discard irrelevant changes. One fairly incremental change is to useReadDirectoryChangesW
which indicates exactly what changed. I think this can be broken down into three parts:FindFirstChangeNotification
withReadDirectoryChangesW
. Normally this would be hard, but winfile'sChangeFileSystem
function is almost a direct translation of the output ofReadDirectoryChangesW
. Most of the changes here would be deleting code used to work around the limitations ofFindFirstChangeNotification
- theFSC_REFRESH
logic, the timer, etc.ReadDirectoryChangesExW
which offers another cute optimization by providing file attributes as part of the notification (so changes to non-directories can be immediately ignored with no processing.)ChangeFileSystem
and let this be driven through external notifications. Currently winfile is a bit split-brained in that it receives both internal and external notifications, and by applying a delay to external notifications, ensures the internal ones take precedence. But if internal and external are happening at the same time without a delay and performing explicit changes, it'd be relatively easy to create race conditions that leave the UI out of sync with the file system. Previously the internal changes were necessary to create a responsive UI when external changes can only indicate "something changed" and require a rescan, but withReadDirectoryChangesW
the UI could be fairly responsive without needing explicit internal change notifications.