Partially address #7385

This does not fully work on Windows, but is no worse than the current situation
Merge pull request #7418 from ihnorton/dir_perms

Partially address #7385