问题描述
几个星期前,我使用std :: ifstream读取一些文件,它是立即失败,打开,因为文件大于4GB。当时我无法找到一个体面的答案,为什么它被限制为32位文件大小,所以我自己使用原生操作系统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.
所以,我的问题然后:有一种方法来处理大小超过4GB的文件大小使用std :: ifstream / std :: ostream(IE:标准c ++)
So, my question then: Is there a way to handle files greater than 4GB in size using std::ifstream/std::ostream (IE: standard c++)
编辑:使用STL实现从VC 9编译器(Visual Studio 2008)。
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();
可以显示当前最大值。
支持较大的文件。
这篇关于使用c ++ stl读取大于4GB的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!