Reading files larger than 4GB using c++ stl(使用 c++ stl 读取大于 4GB 的文件)
问题描述
几周前,我使用 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 的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 c++ stl 读取大于 4GB 的文件


基础教程推荐
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 常量变量在标题中不起作用 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 在 C++ 中计算滚动/移动平均值 2021-01-01