0ad/source/lib/file
wraitii 87a2c3347f Make real directory paths on the VFS predictable (retry)
This is the same commit as 4bb31f084e, reverted in 5d1899785a. Noted
issues were fixed.

Partial revert/fix of 2f19cf86d3 and 2567fee329.

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 c0c8132dd4'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.
It also makes it explicit that a directory must be passed to Mount().

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

Differential Revision: https://code.wildfiregames.com/D3728
This was SVN commit r25107.
2021-03-23 12:46:59 +00:00
..
archive Refactors smart pointers creation, reduces code duplication and improves exception safety. 2021-02-13 23:53:40 +00:00
common Make real directory paths on the VFS predictable (retry) 2021-03-23 12:46:59 +00:00
disabled_tests Remove VFS cache, because it is less effective and less efficient than the OS cache (and partially redundant with higher level application caches). 2017-12-10 17:33:03 +00:00
io Remove UniqueRange custom code in favour of unique_ptr 2020-11-22 13:43:19 +00:00
vfs Make real directory paths on the VFS predictable (retry) 2021-03-23 12:46:59 +00:00
file_system.cpp Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +00:00
file_system.h Further header & precompiled cleanup, fix no-PCH builds. 2020-12-09 14:39:14 +00:00
file.cpp Make all Wildfire Games copyright headers consistent by always ending with a period and using (C) instead of (c). 2017-07-10 14:26:24 +00:00
file.h Fix compiler warnings on VS 2015, refs #3439, refs #5069. 2018-03-10 09:58:53 +00:00