This is D3217 opened again, as there was a crash on windows at the game start, that I need to fix.
See the diff for the original discussion. Below the commit message.
----
Partial revert/fix of rP13167 and rP13472.
Before this diff, it was possible for a mod containing a cache/ or a config/ folder to get written to incorrectly.
The issue is VFS can map multiple directories to one 'virtual' path, for reading mods. However, writing data is problematic: which path to choose?
The only viable solution is to use a path relative to the highest priority directory encountered in the VFS path, or write paths could be 'hijacked' by lower-priority mods.
This fixes these issues by:
- Adding a new lookup mode ('Real-path') that explicitly picks the real path relative to the highest-priority subdirectory in the VFS Path.
- Preventing overwriting a real directory with a lower priority one in general.
- Revert rP8082's GetRealPath change, re-introducing the function as GetOriginalPath.
This also cleans up some duplication that led to empty mod folders in the user mod path, and cleans up loading the 'user' mod.
Note that the new 'realpath' lookup can still be somewhat complex with many mount points at various hierarchy levels, but it is at least predictable/deterministic without having to be careful about populating order.
Fixes #2553