
For portability it's best to stick to the win32 API.
Sorry ... I didn't realize that was VC++ only. It looks like the Win32 API call to set a file's length directly (without writing out bytes to a newly created file) is: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base... *BOOL* *SetFileValidData(* *HANDLE* /hFile/*, * *LONGLONG* /ValidDataLength/* **); * In any case it looks like this SetFileValidData for win32, and ftruncate for POSIX, could be used by memmap.c to support automatic creation of an appropriately sized backing file in the constructor for mapped_file (and the constructor for mapped output files in the IO lib could expose this). I still think a truncate/SetFileValidData wrapper would be nice for the filesystem lib. I'm willing to code this if people think it's a good idea. It frees users from having to first create an empty file of the right length first.