comparison data/fileio/BZipFileDevice.cpp @ 1599:ce185d4dd408 bqaudiostream

Merge from default branch
author Chris Cannam
date Wed, 23 Jan 2019 14:43:43 +0000
parents 70e172e6cc59
children
comparison
equal deleted inserted replaced
1598:d2555df635ec 1599:ce185d4dd408
29 #endif 29 #endif
30 30
31 BZipFileDevice::BZipFileDevice(QString fileName) : 31 BZipFileDevice::BZipFileDevice(QString fileName) :
32 m_fileName(fileName), 32 m_fileName(fileName),
33 m_qfile(fileName), 33 m_qfile(fileName),
34 m_file(0), 34 m_file(nullptr),
35 m_bzFile(0), 35 m_bzFile(nullptr),
36 m_atEnd(true), 36 m_atEnd(true),
37 m_ok(true) 37 m_ok(true)
38 { 38 {
39 } 39 }
40 40
118 int bzError = BZ_OK; 118 int bzError = BZ_OK;
119 m_bzFile = BZ2_bzWriteOpen(&bzError, m_file, 9, 0, 0); 119 m_bzFile = BZ2_bzWriteOpen(&bzError, m_file, 9, 0, 0);
120 120
121 if (!m_bzFile) { 121 if (!m_bzFile) {
122 fclose(m_file); 122 fclose(m_file);
123 m_file = 0; 123 m_file = nullptr;
124 m_qfile.close(); 124 m_qfile.close();
125 setErrorString(tr("Failed to open bzip2 stream for writing")); 125 setErrorString(tr("Failed to open bzip2 stream for writing"));
126 m_ok = false; 126 m_ok = false;
127 return false; 127 return false;
128 } 128 }
148 m_ok = false; 148 m_ok = false;
149 return false; 149 return false;
150 } 150 }
151 151
152 int bzError = BZ_OK; 152 int bzError = BZ_OK;
153 m_bzFile = BZ2_bzReadOpen(&bzError, m_file, 0, 0, NULL, 0); 153 m_bzFile = BZ2_bzReadOpen(&bzError, m_file, 0, 0, nullptr, 0);
154 154
155 if (!m_bzFile) { 155 if (!m_bzFile) {
156 fclose(m_file); 156 fclose(m_file);
157 m_file = 0; 157 m_file = nullptr;
158 m_qfile.close(); 158 m_qfile.close();
159 setErrorString(tr("Failed to open bzip2 stream for reading")); 159 setErrorString(tr("Failed to open bzip2 stream for reading"));
160 m_ok = false; 160 m_ok = false;
161 return false; 161 return false;
162 } 162 }
193 if (bzError != BZ_OK) { 193 if (bzError != BZ_OK) {
194 setErrorString(tr("bzip2 stream write close error")); 194 setErrorString(tr("bzip2 stream write close error"));
195 } 195 }
196 fclose(m_file); 196 fclose(m_file);
197 m_qfile.close(); 197 m_qfile.close();
198 m_bzFile = 0; 198 m_bzFile = nullptr;
199 m_file = 0; 199 m_file = nullptr;
200 m_ok = false; 200 m_ok = false;
201 return; 201 return;
202 } 202 }
203 203
204 if (openMode() & ReadOnly) { 204 if (openMode() & ReadOnly) {
206 if (bzError != BZ_OK) { 206 if (bzError != BZ_OK) {
207 setErrorString(tr("bzip2 stream read close error")); 207 setErrorString(tr("bzip2 stream read close error"));
208 } 208 }
209 fclose(m_file); 209 fclose(m_file);
210 m_qfile.close(); 210 m_qfile.close();
211 m_bzFile = 0; 211 m_bzFile = nullptr;
212 m_file = 0; 212 m_file = nullptr;
213 m_ok = false; 213 m_ok = false;
214 return; 214 return;
215 } 215 }
216 216
217 setErrorString(tr("Internal error (close for neither read nor write)")); 217 setErrorString(tr("Internal error (close for neither read nor write)"));