几周前,我使用 std::ifstream 读取一些文件,但打开时立即失败,因为文件大于 4GB.当时我找不到合适的答案来解释为什么它被限制为 32 位文件大小,所以我使用原生 OS API 编写了自己的 API.
A few weeks back I was using std::ifstream to read in some files and it was failing immediately on open because the file was larger than 4GB. At the time I couldnt find a decent answer as to why it was limited to 32 bit files sizes, so I wrote my own using native OS API.
那么,我的问题是:有没有办法使用 std::ifstream/std::ostream(IE:标准 C++)处理大于 4GB 的文件
So, my question then: Is there a way to handle files greater than 4GB in size using std::ifstream/std::ostream (IE: standard c++)
使用来自 VC 9 编译器 (Visual Studio 2008) 的 STL 实现.当然必须有标准的方法来支持大于 4GB 的文件大小.
Using the STL implementation from the VC 9 compiler (Visual Studio 2008). Surely there has to be standard way to support file sizes larger than 4GB.
显然这取决于库如何实现 off_t
.
Apparently it depends on how off_t
is implemented by the library.
#include <streambuf>
__int64_t temp=std::numeric_limits<std::streamsize>::max();
为您提供当前的最大值.
gives you what the current max is.
STLport 支持更大的文件.
这篇关于使用 c++ stl 读取大于 4GB 的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!