icculus / physfs

A portable, flexible file i/o abstraction.
https://icculus.org/physfs/
zlib License
560 stars 98 forks source link

Add support for mount priority #2

Open criptych opened 3 years ago

criptych commented 3 years ago

This allows limited manipulation of the search path without unmounting/remounting to get mounts in the right order.

It makes negligible changes to the API, repurposing the existing "appendToPath" parameter to PHYSFS_mount* and handling typical "flag" values (0, 1, -1) in such a way that current programs should have no change in function. An int is added to each DirHandle to store the mount's priority for later comparison.

I had a use case in mind when I initially wrote this, but the specifics are lost to memory (that was almost 3 years ago). Something that comes to mind is dynamically mounted DLC and UGC: one might mount UGC at a high priority (say 5), so that it overrides DLC at priority 10, which in turn overrides base content at priority 20. If a new DLC package is mounted mid-game, also at priority 10, it won't inadvertently override mounted UGC.