MCPcopy Create free account
hub / github.com/PDAL/PDAL / run

Method run

pdal/compression/DeflateCompression.cpp:82–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80
81private:
82 void run(const char *buf, size_t bufsize, int mode)
83 {
84 auto handleError = [](int ret) -> void
85 {
86 switch (ret)
87 {
88 case Z_OK:
89 case Z_STREAM_END:
90 return;
91 case Z_STREAM_ERROR:
92 throw compression_error("Internal error.");
93 case Z_DATA_ERROR:
94 throw compression_error("Corrupted data.");
95 case Z_MEM_ERROR:
96 throw compression_error("Memory allocation failure.");
97 default:
98 std::cerr << "Compression error !\n";
99 throw compression_error();
100 }
101 };
102
103 if (buf)
104 {
105 m_strm.avail_in = bufsize;
106 m_strm.next_in = reinterpret_cast<unsigned char *>(
107 const_cast<char *>(buf));
108 }
109 int ret = Z_OK;
110 do
111 {
112 m_strm.avail_out = CHUNKSIZE;
113 m_strm.next_out = m_tmpbuf;
114 ret = ::deflate(&m_strm, mode);
115 handleError(ret);
116 size_t written = CHUNKSIZE - m_strm.avail_out;
117 if (written)
118 m_cb(reinterpret_cast<char *>(m_tmpbuf), written);
119 } while (m_strm.avail_out == 0);
120 }
121
122private:
123 BlockCb m_cb;

Callers

nothing calls this directly

Calls 1

compression_errorClass · 0.85

Tested by

no test coverage detected