Mercurial > hg > svcore
comparison data/fileio/BZipFileDevice.cpp @ 843:e802e550a1f2
Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author | Chris Cannam |
---|---|
date | Tue, 26 Nov 2013 13:35:08 +0000 |
parents | 1424aa29ae95 |
children | cc27f35aa75c |
comparison
equal
deleted
inserted
replaced
842:23d3a6eca5c3 | 843:e802e550a1f2 |
---|---|
17 | 17 |
18 #include <bzlib.h> | 18 #include <bzlib.h> |
19 | 19 |
20 #include <iostream> | 20 #include <iostream> |
21 | 21 |
22 #include "base/Debug.h" | |
23 | |
22 BZipFileDevice::BZipFileDevice(QString fileName) : | 24 BZipFileDevice::BZipFileDevice(QString fileName) : |
23 m_fileName(fileName), | 25 m_fileName(fileName), |
24 m_file(0), | 26 m_file(0), |
25 m_bzFile(0), | 27 m_bzFile(0), |
26 m_atEnd(true), | 28 m_atEnd(true), |
86 setErrorString(tr("Failed to open bzip2 stream for writing")); | 88 setErrorString(tr("Failed to open bzip2 stream for writing")); |
87 m_ok = false; | 89 m_ok = false; |
88 return false; | 90 return false; |
89 } | 91 } |
90 | 92 |
91 // std::cerr << "BZipFileDevice: opened \"" << m_fileName << "\" for writing" << std::endl; | 93 // cerr << "BZipFileDevice: opened \"" << m_fileName << "\" for writing" << endl; |
92 | 94 |
93 setErrorString(QString()); | 95 setErrorString(QString()); |
94 setOpenMode(mode); | 96 setOpenMode(mode); |
95 return true; | 97 return true; |
96 } | 98 } |
113 setErrorString(tr("Failed to open bzip2 stream for reading")); | 115 setErrorString(tr("Failed to open bzip2 stream for reading")); |
114 m_ok = false; | 116 m_ok = false; |
115 return false; | 117 return false; |
116 } | 118 } |
117 | 119 |
118 // std::cerr << "BZipFileDevice: opened \"" << m_fileName << "\" for reading" << std::endl; | 120 // cerr << "BZipFileDevice: opened \"" << m_fileName << "\" for reading" << endl; |
119 | 121 |
120 m_atEnd = false; | 122 m_atEnd = false; |
121 | 123 |
122 setErrorString(QString()); | 124 setErrorString(QString()); |
123 setOpenMode(mode); | 125 setOpenMode(mode); |
141 int bzError = BZ_OK; | 143 int bzError = BZ_OK; |
142 | 144 |
143 if (openMode() & WriteOnly) { | 145 if (openMode() & WriteOnly) { |
144 unsigned int in = 0, out = 0; | 146 unsigned int in = 0, out = 0; |
145 BZ2_bzWriteClose(&bzError, m_bzFile, 0, &in, &out); | 147 BZ2_bzWriteClose(&bzError, m_bzFile, 0, &in, &out); |
146 // std::cerr << "Wrote bzip2 stream (in=" << in << ", out=" << out << ")" << std::endl; | 148 // cerr << "Wrote bzip2 stream (in=" << in << ", out=" << out << ")" << endl; |
147 if (bzError != BZ_OK) { | 149 if (bzError != BZ_OK) { |
148 setErrorString(tr("bzip2 stream write close error")); | 150 setErrorString(tr("bzip2 stream write close error")); |
149 } | 151 } |
150 fclose(m_file); | 152 fclose(m_file); |
151 m_bzFile = 0; | 153 m_bzFile = 0; |
180 | 182 |
181 // SVDEBUG << "BZipFileDevice::readData: requested " << maxSize << ", read " << read << endl; | 183 // SVDEBUG << "BZipFileDevice::readData: requested " << maxSize << ", read " << read << endl; |
182 | 184 |
183 if (bzError != BZ_OK) { | 185 if (bzError != BZ_OK) { |
184 if (bzError != BZ_STREAM_END) { | 186 if (bzError != BZ_STREAM_END) { |
185 std::cerr << "BZipFileDevice::readData: error condition" << std::endl; | 187 cerr << "BZipFileDevice::readData: error condition" << endl; |
186 setErrorString(tr("bzip2 stream read error")); | 188 setErrorString(tr("bzip2 stream read error")); |
187 m_ok = false; | 189 m_ok = false; |
188 return -1; | 190 return -1; |
189 } else { | 191 } else { |
190 // SVDEBUG << "BZipFileDevice::readData: reached end of file" << endl; | 192 // SVDEBUG << "BZipFileDevice::readData: reached end of file" << endl; |
202 BZ2_bzWrite(&bzError, m_bzFile, (void *)data, maxSize); | 204 BZ2_bzWrite(&bzError, m_bzFile, (void *)data, maxSize); |
203 | 205 |
204 // SVDEBUG << "BZipFileDevice::writeData: " << maxSize << " to write" << endl; | 206 // SVDEBUG << "BZipFileDevice::writeData: " << maxSize << " to write" << endl; |
205 | 207 |
206 if (bzError != BZ_OK) { | 208 if (bzError != BZ_OK) { |
207 std::cerr << "BZipFileDevice::writeData: error condition" << std::endl; | 209 cerr << "BZipFileDevice::writeData: error condition" << endl; |
208 setErrorString("bzip2 stream write error"); | 210 setErrorString("bzip2 stream write error"); |
209 m_ok = false; | 211 m_ok = false; |
210 return -1; | 212 return -1; |
211 } | 213 } |
212 | 214 |