Mercurial > hg > svcore
comparison data/fileio/BZipFileDevice.cpp @ 742:c10cb8782576 coreaudio_tests
Merge from branch "default"
author | Chris Cannam |
---|---|
date | Sun, 01 Jul 2012 11:53:00 +0100 |
parents | 1424aa29ae95 |
children | e802e550a1f2 |
comparison
equal
deleted
inserted
replaced
666:4efa7429cd85 | 742:c10cb8782576 |
---|---|
28 { | 28 { |
29 } | 29 } |
30 | 30 |
31 BZipFileDevice::~BZipFileDevice() | 31 BZipFileDevice::~BZipFileDevice() |
32 { | 32 { |
33 // std::cerr << "BZipFileDevice::~BZipFileDevice(" << m_fileName.toStdString() << ")" << std::endl; | 33 // SVDEBUG << "BZipFileDevice::~BZipFileDevice(" << m_fileName << ")" << endl; |
34 if (m_bzFile) close(); | 34 if (m_bzFile) close(); |
35 } | 35 } |
36 | 36 |
37 bool | 37 bool |
38 BZipFileDevice::isOK() const | 38 BZipFileDevice::isOK() const |
86 setErrorString(tr("Failed to open bzip2 stream for writing")); | 86 setErrorString(tr("Failed to open bzip2 stream for writing")); |
87 m_ok = false; | 87 m_ok = false; |
88 return false; | 88 return false; |
89 } | 89 } |
90 | 90 |
91 // std::cerr << "BZipFileDevice: opened \"" << m_fileName.toStdString() << "\" for writing" << std::endl; | 91 // std::cerr << "BZipFileDevice: opened \"" << m_fileName << "\" for writing" << std::endl; |
92 | 92 |
93 setErrorString(QString()); | 93 setErrorString(QString()); |
94 setOpenMode(mode); | 94 setOpenMode(mode); |
95 return true; | 95 return true; |
96 } | 96 } |
113 setErrorString(tr("Failed to open bzip2 stream for reading")); | 113 setErrorString(tr("Failed to open bzip2 stream for reading")); |
114 m_ok = false; | 114 m_ok = false; |
115 return false; | 115 return false; |
116 } | 116 } |
117 | 117 |
118 // std::cerr << "BZipFileDevice: opened \"" << m_fileName.toStdString() << "\" for reading" << std::endl; | 118 // std::cerr << "BZipFileDevice: opened \"" << m_fileName << "\" for reading" << std::endl; |
119 | 119 |
120 m_atEnd = false; | 120 m_atEnd = false; |
121 | 121 |
122 setErrorString(QString()); | 122 setErrorString(QString()); |
123 setOpenMode(mode); | 123 setOpenMode(mode); |
176 if (m_atEnd) return 0; | 176 if (m_atEnd) return 0; |
177 | 177 |
178 int bzError = BZ_OK; | 178 int bzError = BZ_OK; |
179 int read = BZ2_bzRead(&bzError, m_bzFile, data, maxSize); | 179 int read = BZ2_bzRead(&bzError, m_bzFile, data, maxSize); |
180 | 180 |
181 // std::cerr << "BZipFileDevice::readData: requested " << maxSize << ", read " << read << std::endl; | 181 // SVDEBUG << "BZipFileDevice::readData: requested " << maxSize << ", read " << read << endl; |
182 | 182 |
183 if (bzError != BZ_OK) { | 183 if (bzError != BZ_OK) { |
184 if (bzError != BZ_STREAM_END) { | 184 if (bzError != BZ_STREAM_END) { |
185 std::cerr << "BZipFileDevice::readData: error condition" << std::endl; | 185 std::cerr << "BZipFileDevice::readData: error condition" << std::endl; |
186 setErrorString(tr("bzip2 stream read error")); | 186 setErrorString(tr("bzip2 stream read error")); |
187 m_ok = false; | 187 m_ok = false; |
188 return -1; | 188 return -1; |
189 } else { | 189 } else { |
190 // std::cerr << "BZipFileDevice::readData: reached end of file" << std::endl; | 190 // SVDEBUG << "BZipFileDevice::readData: reached end of file" << endl; |
191 m_atEnd = true; | 191 m_atEnd = true; |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 return read; | 195 return read; |
199 BZipFileDevice::writeData(const char *data, qint64 maxSize) | 199 BZipFileDevice::writeData(const char *data, qint64 maxSize) |
200 { | 200 { |
201 int bzError = BZ_OK; | 201 int bzError = BZ_OK; |
202 BZ2_bzWrite(&bzError, m_bzFile, (void *)data, maxSize); | 202 BZ2_bzWrite(&bzError, m_bzFile, (void *)data, maxSize); |
203 | 203 |
204 // std::cerr << "BZipFileDevice::writeData: " << maxSize << " to write" << std::endl; | 204 // SVDEBUG << "BZipFileDevice::writeData: " << maxSize << " to write" << endl; |
205 | 205 |
206 if (bzError != BZ_OK) { | 206 if (bzError != BZ_OK) { |
207 std::cerr << "BZipFileDevice::writeData: error condition" << std::endl; | 207 std::cerr << "BZipFileDevice::writeData: error condition" << std::endl; |
208 setErrorString("bzip2 stream write error"); | 208 setErrorString("bzip2 stream write error"); |
209 m_ok = false; | 209 m_ok = false; |
210 return -1; | 210 return -1; |
211 } | 211 } |
212 | 212 |
213 // std::cerr << "BZipFileDevice::writeData: wrote " << maxSize << std::endl; | 213 // SVDEBUG << "BZipFileDevice::writeData: wrote " << maxSize << endl; |
214 | 214 |
215 return maxSize; | 215 return maxSize; |
216 } | 216 } |
217 | 217 |