fix memory-mapped file open to only resize when required and to resize correctly