gzstream在windows上通过mingw注入CR + LF
gzstream on windows via mingw: injects CR + LF
我从站点下载了源代码并构建了它,但是当我运行测试时,所有压缩的文件都有CR+LF行结尾,而不仅仅是LF,这使得解压缩的文件与原始文件不同。
我正在查看源代码,但似乎他们已经以二进制模式打开了文件:
gzstreambuf* gzstreambuf::open( const char* name, int open_mode) {
if ( is_open())
return (gzstreambuf*)0;
mode = open_mode;
// no append nor read/write mode
if ((mode & std::ios::ate) || (mode & std::ios::app)
|| ((mode & std::ios::in) && (mode & std::ios::out)))
return (gzstreambuf*)0;
char fmode[10];
char* fmodeptr = fmode;
if ( mode & std::ios::in)
*fmodeptr++ = 'r';
else if ( mode & std::ios::out)
*fmodeptr++ = 'w';
*fmodeptr++ = 'b';
*fmodeptr = ' ';
file = gzopen( name, fmode);
if (file == 0)
return (gzstreambuf*)0;
opened = 1;
return this;
}
我真的很喜欢使用这段代码,因为它看起来非常干净,而且在mingw gcc上编译起来毫不费力。唯一的问题是这件棘手的事情,如果我能想出一个解决方案,我可以让它顺其自然。
我已经成功地实现了我的解决方案。虽然gzstream看起来不错,但我还是硬着头写了一些直接使用zlib的代码。事实证明,一点也不坏,因为zlib在那里隐藏了帮助器,而且zlib.h
本身也有很多有用的评论。
ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen));
很简单。
当然,没有更多的问题与伪0x0D
回车字符!
std::ios::binary在哪里??
在UNIX平台上,它通常是不必要的,所以有些人在不应该省略它的时候忽略了它。
相关文章:
- 无法使用加载库卸载注入的 dll (C++)
- 将 dll 文件注入 UWP
- 将具有固定签名的自定义函数名称注入 CRTP
- 发生注入类名时会发生什么情况?(C++)
- 作为指针注入类后重新创建堆栈对象不好吗?
- 如何使用可视化代码和平台IO将环境变量注入CPP文件?
- 限定的依赖名称查找,其中包含基类的注入类名
- 如何在窗口中使用注入的 dll 中的参数调用函数
- PostgresSQL - SQL Ready 语句与字符串转义,防止 SQL 注入攻击
- Windows 将标准的 C 文件结构注入到正在运行的进程中
- 当注入程序的内存空间时,如何读取从 0 到 0xFFFFFFFFF 的每个字节?我正在创建模式扫描仪
- 读取进程内存多级指针(DLL 注入)
- 如何在不诉诸依赖注入的情况下模拟遗留函数?
- c++ 注入器运行,但不注入 DLL
- 为什么我的DLL只能注入手动映射
- 类成员和依赖项注入的对象与引用
- 注入类名作为类型
- C++如何在派生类上进行依赖项注入
- 如何仅在一个窗口中忽略注入的输入?
- gzstream在windows上通过mingw注入CR + LF