- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我从the site 下载了源代码并构建了它,但是当我运行测试时,所有压缩文件都有 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 = '\0';
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
回车字符不再有问题!
关于c++ - gzstream 在 Windows 上通过 mingw : injects CR + LF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7445576/
我正在尝试在 xcode 6.1、libz.1.dylib 下使用 gzstream 1.5 进行 ios 开发。 这个库是很久以前写的。 我发现 class igzstream : public g
我必须处理用 gzipped 压缩的大文件。我需要访问部分行,不一定按顺序访问。因此,我想遍历所有文件,同时在我感兴趣的行记录流位置。然后,利用这些流位置快速检索我需要的信息。 为此,我使用 gzst
我编写了 gzstream 1.5 的简单包装器,用于 rapidjson 0.1(ios、xcode 6.1)。 问题:我必须在 Peek() 和 Take() 中检查 eof。否则,我得到 '\3
我从the site 下载了源代码并构建了它,但是当我运行测试时,所有压缩文件都有 CR+LF 行结尾,而不仅仅是 LF,这使得解压缩的文件与原始文件不同。 我正在查看源代码,但似乎他们已经在以二进制
我想用我的 C++ 脚本读写压缩文件。为此,我使用 gzstream 库。它适用于像这样一个非常简单的例子: string inFile="/path/inputfile.gz"; igzstream
我是一名优秀的程序员,十分优秀!