I try to write to a large file, but it seems like it does not work for files larger than 2GB. I have tried with boost::iostreams::file_sink. Is this just a limit with the boost stream? Is there some other way I can write a large file on Win64 and win32?
+7
A:
This depends on:
- The file system which you're using. Old file systems like FAT allow only files up to 2GB. Use NTFS.
- Your library must be compiled to allow large files (64bit seek offsets). If they use 32bit ints to seek in file (check the arguments and results of the calls "seek" and "tell"), you can only ever access 2GB (2^31bits, the 32th is the sign +/-)
This might also help: http://www.boost.org/doc/libs/1_37_0/libs/iostreams/doc/faq.html#offsets
Aaron Digulla
2008-11-19 14:59:52
"Thirtytwoth"? I just couldn't help myself :)
korona
2008-11-19 15:46:39
"We're talking grammar here; sense is another issue" - I don't remember where I read that.
Aaron Digulla
2008-11-20 08:29:31
Thanks :) offset_to_position found in your link made the trick
2008-11-20 15:45:12
Be careful when comparing two streampos, as building for 32-bit in VS2005 operator== will truncate to 32-bit before comparison. Better is to use position_to_offset and comparing the offset.
dalle
2009-02-20 22:40:02
Thanks; I've clarified that bit.
Aaron Digulla
2009-02-23 09:17:01
+5
A:
In Win32/64 the ReadFile & WriteFile can write files larger than 4gb. The positioning is done via a 64bit _LARGE_INTEGER value in SetFilePointerEx. Likewise to get the file size you need GetFileSizeEx and not the basic GetFileSize.
graham.reeds
2008-11-19 15:13:24
+1
A:
In NTFS the only real limit is the size of the volume. If you want to test this out you can create a dummy file using the command-line:
fsutil file createnew [filename] [validdatalength]
Ex:
fsutil file createnew TestFile.bin 65536000000
That should create a 64GB file assuming you have an NTFS volume.
JGeiser
2008-11-19 16:34:20