| 74 | } |
| 75 | |
| 76 | bool Compression::open(Format format, FlushMode flush, int windowBits) { |
| 77 | ai_assert(mImpl != nullptr); |
| 78 | |
| 79 | if (mImpl->mOpen) { |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | // build a zlib stream |
| 84 | mImpl->mZSstream.opaque = Z_NULL; |
| 85 | mImpl->mZSstream.zalloc = Z_NULL; |
| 86 | mImpl->mZSstream.zfree = Z_NULL; |
| 87 | mImpl->mFlushMode = flush; |
| 88 | if (format == Format::Binary) { |
| 89 | mImpl->mZSstream.data_type = Z_BINARY; |
| 90 | } else { |
| 91 | mImpl->mZSstream.data_type = Z_ASCII; |
| 92 | } |
| 93 | |
| 94 | // raw decompression without a zlib or gzip header |
| 95 | if (windowBits == 0) { |
| 96 | inflateInit(&mImpl->mZSstream); |
| 97 | } else { |
| 98 | inflateInit2(&mImpl->mZSstream, windowBits); |
| 99 | } |
| 100 | mImpl->mOpen = true; |
| 101 | |
| 102 | return mImpl->mOpen; |
| 103 | } |
| 104 | |
| 105 | static int getFlushMode(Compression::FlushMode flush) { |
| 106 | int z_flush = 0; |
no outgoing calls
no test coverage detected