写入大文件

发布于 2024-07-08 11:06:25 字数 121 浏览 8 评论 0原文

我尝试写入一个大文件,但它似乎不适用于大于 2GB 的文件。 我尝试过使用 boost::iostreams::file_sink。 这只是升压流的限制吗? 还有其他方法可以在 Win64 和 win32 上写入大文件吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

玩心态 2024-07-15 11:06:25

这取决于:

  • 您正在使用的文件系统。 FAT 等旧文件系统仅允许最大 2GB 的文件。 使用 NTFS。
  • 您的库必须编译为允许大文件(64 位查找偏移)。 如果他们使用 32 位整数在文件中查找(检查调用“seek”和“tell”的参数和结果),您只能访问 2GB(2^31 位,第 32 位是符​​号 +/-)

这也可能帮助:http://www.boost。 org/doc/libs/1_37_0/libs/iostreams/doc/faq.html#offsets

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

少女七分熟 2024-07-15 11:06:25

在 Win32/64 中 ReadFile & WriteFile可以写入大于4GB的文件。 定位是通过 SetFilePointerEx。 同样,要获取您需要的文件大小 GetFileSizeEx 和不是基本的 GetFileSize。

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.

笑着哭最痛 2024-07-15 11:06:25

在 NTFS 中,唯一真正的限制是卷的大小。 如果您想对此进行测试,可以使用命令行创建一个虚拟文件:
fsutil file createnew [文件名] [有效数据长度]
例如:
fsutil 文件 createnew TestFile.bin 65536000000
假设您有一个 NTFS 卷,这应该会创建一个 64GB 的文件。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文