c++中的压缩文件IO
compressed file IO in c++
我有一个模拟,在这个模拟中,我需要在代码运行时转储大量数据,通常大约在50GB左右,这通常以周为单位。现在,我正在将数据导出为legacy ASCII VTK
文件。
我想知道是否有任何方法可以在数据写入磁盘时压缩数据,这样我就可以节省一些空间(我需要同时运行多个版本的代码)。如果可能的话,我更喜欢标准图书馆的东西。
如果您可以使用boost,请查看zlib过滤器压缩器和解压缩器
#include <fstream>
#include <iostream>
#include <boost/iostreams/filtering_streambuf.hpp>
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/zlib.hpp>
int main()
{
using namespace std;
ifstream file("hello.z", ios_base::in | ios_base::binary);
filtering_streambuf<input> in;
in.push(zlib_decompressor());
in.push(file);
boost::iostreams::copy(in, cout);
}
相关文章:
- 为什么在读取文件大小时文件IO速度会发生变化
- C++中真正的异步文件 IO
- Xcode OSX上的C++构建失败,出现多个错误文件IO..不可用:在macOS 10.15中引入
- 如何使用C 文件IO修复程序
- C++ 使用数字删除文件 io 行
- 我们是否需要互斥锁来执行多线程文件 IO
- C++带有字符串和浮点的文件 IO
- 多线程文件 IO 程序在线程数增加时行为不可预测
- 在C++程序中,IO/文件 IO 操作的优先级是否高于 CPU 操作
- C++ 中的文件 IO 出错。在抛出 'std::length_error' 的实例后调用的终止 what(): basic_string::调整大小
- 文件IO循环错误
- 如何确保数据刷新到文件 IO (WriteFile()) 上的 HDD(未缓冲)
- Win32 文件 IO 工作,但打开 et.失败.这是怎么回事
- C++ 中的详细文件 IO 错误报告
- c++中的压缩文件IO
- 提供带有libjpeg的自定义文件IO
- 在C++文件IO期间捕获所有错误(或ios对象中的任何错误)的最佳实践
- 带有tmpnam的C++文件IO永久临时文件
- 文件IO中的可移植性问题
- 使用/dev/random的文件io花费的时间太长