vmap-rs
vmap-rs copied to clipboard
Add functions for mapping multiple files adjacent in memory
This may be a somewhat specific use case, but I would like to be able to map multiple files adjacent in memory (two different files, though I could see a single mirrored file being useful as well). It may be possible to generalize the number of files with an iterator?
Oh that's an interesting idea! Assuming N
files, would you expect that at least N-1
files could be mapped evenly to a page size? I suspect you wouldn't want gaps at the end of each "sub-mapped" file. If one of these files is not an exact multiple what do you think should happen? Error? Truncate the mapped region down to the nearest multiple? What if the nearest multiple is 0
(i.e. the file size is less than a page size), is that ok to just skip?
On Windows, this might be a bit tricker. I think it would be possible to map each subsequent file at a page boundary (4k) rather than the allocation granularity (64k). At a minimum, the file size requirement could be a multiple of the allocation granularity, but I suspect this would just be the required over-allocation for the last file.
In my particular use case I can choose the file sizes, but in general, I do think the files will probably need to be multiples of the page size or allocation granularity. I think it should probably support all of the same configuration parameters as a plain file mapping for each file. I'm not sure what should happen if the sizes don't work, probably an error (if the size is smaller than the file I would expect it to just map a portion of the file, like a regular file mapping)