[physfs] mmap'ed files

Ryan C. Gordon icculus at icculus.org
Tue Feb 7 12:23:56 EST 2012

On 02/06/2012 03:05 PM, fungos wrote:
> I think that mmap'ed files aren't implemented on 2.0.2 right?


We can't offer an mmap()-like API for accessing files, because it 
wouldn't be helpful for files inside archives that might be stored as 
compressed data.

While we _could_ mmap() an entire archive behind the scenes, it's not 
really safe to do so unconditionally, because a multi-gigabyte .zip file 
would eat all of the address space of a 32-bit process.

The best bet here might be to mmap() smaller files behind the scenes (or 
mmap() everything in a 64-bit process). Alternately, the 2.1 branch lets 
you supply your own i/o implementations, so you could use 
PHYSFS_mountIo() to load an archive and work out of an mmap()'d buffer.

All that being said: we don't really load a whole archive to 
RAM...mostly we read small pieces from it as necessary, so it's not 
necessarily much of a drain on system resources to _not_ mmap it.


More information about the physfs mailing list