comparison transform/FileFeatureWriter.cpp @ 690:1424aa29ae95

Seems to be a bad idea to use plain DEBUG symbol on OS/X (system wants it)
author Chris Cannam
date Tue, 14 Jun 2011 15:26:52 +0100
parents 06f13a3b9e9e
children f5cd33909744
comparison
equal deleted inserted replaced
689:573d45e9487b 690:1424aa29ae95
44 if (m_support & SupportOneFilePerTrackTransform) { 44 if (m_support & SupportOneFilePerTrackTransform) {
45 m_manyFiles = true; 45 m_manyFiles = true;
46 } else if (m_support & SupportOneFileTotal) { 46 } else if (m_support & SupportOneFileTotal) {
47 m_singleFileName = QString("output.%1").arg(m_extension); 47 m_singleFileName = QString("output.%1").arg(m_extension);
48 } else { 48 } else {
49 DEBUG << "FileFeatureWriter::FileFeatureWriter: ERROR: Invalid support specification " << support << endl; 49 SVDEBUG << "FileFeatureWriter::FileFeatureWriter: ERROR: Invalid support specification " << support << endl;
50 } 50 }
51 } 51 }
52 } 52 }
53 53
54 FileFeatureWriter::~FileFeatureWriter() 54 FileFeatureWriter::~FileFeatureWriter()
58 delete m_streams.begin()->second; 58 delete m_streams.begin()->second;
59 m_streams.erase(m_streams.begin()); 59 m_streams.erase(m_streams.begin());
60 } 60 }
61 while (!m_files.empty()) { 61 while (!m_files.empty()) {
62 if (m_files.begin()->second) { 62 if (m_files.begin()->second) {
63 DEBUG << "FileFeatureWriter::~FileFeatureWriter: NOTE: Closing feature file \"" 63 SVDEBUG << "FileFeatureWriter::~FileFeatureWriter: NOTE: Closing feature file \""
64 << m_files.begin()->second->fileName() << "\"" << endl; 64 << m_files.begin()->second->fileName() << "\"" << endl;
65 delete m_files.begin()->second; 65 delete m_files.begin()->second;
66 } 66 }
67 m_files.erase(m_files.begin()); 67 m_files.erase(m_files.begin());
68 } 68 }
126 m_baseDir = i->second.c_str(); 126 m_baseDir = i->second.c_str();
127 } else if (i->first == "many-files") { 127 } else if (i->first == "many-files") {
128 if (m_support & SupportOneFilePerTrackTransform && 128 if (m_support & SupportOneFilePerTrackTransform &&
129 m_support & SupportOneFilePerTrack) { 129 m_support & SupportOneFilePerTrack) {
130 if (m_singleFileName != "") { 130 if (m_singleFileName != "") {
131 DEBUG << "FileFeatureWriter::setParameters: WARNING: Both one-file and many-files parameters provided, ignoring many-files" << endl; 131 SVDEBUG << "FileFeatureWriter::setParameters: WARNING: Both one-file and many-files parameters provided, ignoring many-files" << endl;
132 } else { 132 } else {
133 m_manyFiles = true; 133 m_manyFiles = true;
134 } 134 }
135 } 135 }
136 } else if (i->first == "one-file") { 136 } else if (i->first == "one-file") {
140 // may be on by default (for any FileFeatureWriter 140 // may be on by default (for any FileFeatureWriter
141 // that supports OneFilePerTrackTransform but not 141 // that supports OneFilePerTrackTransform but not
142 // OneFilePerTrack), so we need to be able to 142 // OneFilePerTrack), so we need to be able to
143 // override it 143 // override it
144 // if (m_manyFiles) { 144 // if (m_manyFiles) {
145 // DEBUG << "FileFeatureWriter::setParameters: WARNING: Both many-files and one-file parameters provided, ignoring one-file" << endl; 145 // SVDEBUG << "FileFeatureWriter::setParameters: WARNING: Both many-files and one-file parameters provided, ignoring one-file" << endl;
146 // } else { 146 // } else {
147 m_singleFileName = i->second.c_str(); 147 m_singleFileName = i->second.c_str();
148 // } 148 // }
149 } 149 }
150 } 150 }
151 } else if (i->first == "stdout") { 151 } else if (i->first == "stdout") {
152 if (m_support & SupportOneFileTotal) { 152 if (m_support & SupportOneFileTotal) {
153 if (m_singleFileName != "") { 153 if (m_singleFileName != "") {
154 DEBUG << "FileFeatureWriter::setParameters: WARNING: Both stdout and one-file provided, ignoring stdout" << endl; 154 SVDEBUG << "FileFeatureWriter::setParameters: WARNING: Both stdout and one-file provided, ignoring stdout" << endl;
155 } else { 155 } else {
156 m_stdout = true; 156 m_stdout = true;
157 } 157 }
158 } 158 }
159 } else if (i->first == "append") { 159 } else if (i->first == "append") {
169 TransformId transformId) 169 TransformId transformId)
170 { 170 {
171 if (m_singleFileName != "") { 171 if (m_singleFileName != "") {
172 if (QFileInfo(m_singleFileName).exists() && !(m_force || m_append)) { 172 if (QFileInfo(m_singleFileName).exists() && !(m_force || m_append)) {
173 cerr << endl << "FileFeatureWriter: ERROR: Specified output file \"" << m_singleFileName << "\" exists and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append flag is specified -- not overwriting" << endl; 173 cerr << endl << "FileFeatureWriter: ERROR: Specified output file \"" << m_singleFileName << "\" exists and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append flag is specified -- not overwriting" << endl;
174 DEBUG << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl; 174 SVDEBUG << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl;
175 return ""; 175 return "";
176 } 176 }
177 return m_singleFileName; 177 return m_singleFileName;
178 } 178 }
179 179
214 214
215 filename = QDir(dirname).filePath(filename); 215 filename = QDir(dirname).filePath(filename);
216 216
217 if (QFileInfo(filename).exists() && !(m_force || m_append)) { 217 if (QFileInfo(filename).exists() && !(m_force || m_append)) {
218 cerr << endl << "FileFeatureWriter: ERROR: Output file \"" << filename << "\" exists (for input file or URL \"" << trackId << "\" and transform \"" << transformId << "\") and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append is specified -- not overwriting" << endl; 218 cerr << endl << "FileFeatureWriter: ERROR: Output file \"" << filename << "\" exists (for input file or URL \"" << trackId << "\" and transform \"" << transformId << "\") and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append is specified -- not overwriting" << endl;
219 DEBUG << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl; 219 SVDEBUG << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl;
220 return ""; 220 return "";
221 } 221 }
222 222
223 return filename; 223 return filename;
224 } 224 }
261 261
262 if (filename == "") { // stdout or failure 262 if (filename == "") { // stdout or failure
263 return 0; 263 return 0;
264 } 264 }
265 265
266 DEBUG << "FileFeatureWriter: NOTE: Using output filename \"" 266 SVDEBUG << "FileFeatureWriter: NOTE: Using output filename \""
267 << filename << "\"" << endl; 267 << filename << "\"" << endl;
268 268
269 if (m_append) { 269 if (m_append) {
270 DEBUG << "FileFeatureWriter: NOTE: Calling reviewFileForAppending" << endl; 270 SVDEBUG << "FileFeatureWriter: NOTE: Calling reviewFileForAppending" << endl;
271 reviewFileForAppending(filename); 271 reviewFileForAppending(filename);
272 } 272 }
273 273
274 QFile *file = new QFile(filename); 274 QFile *file = new QFile(filename);
275 QIODevice::OpenMode mode = (QIODevice::WriteOnly); 275 QIODevice::OpenMode mode = (QIODevice::WriteOnly);
327 327
328 328
329 void 329 void
330 FileFeatureWriter::finish() 330 FileFeatureWriter::finish()
331 { 331 {
332 // DEBUG << "FileFeatureWriter::finish()" << endl; 332 // SVDEBUG << "FileFeatureWriter::finish()" << endl;
333 333
334 if (m_singleFileName != "" || m_stdout) return; 334 if (m_singleFileName != "" || m_stdout) return;
335 335
336 while (!m_streams.empty()) { 336 while (!m_streams.empty()) {
337 m_streams.begin()->second->flush(); 337 m_streams.begin()->second->flush();
338 delete m_streams.begin()->second; 338 delete m_streams.begin()->second;
339 m_streams.erase(m_streams.begin()); 339 m_streams.erase(m_streams.begin());
340 } 340 }
341 while (!m_files.empty()) { 341 while (!m_files.empty()) {
342 if (m_files.begin()->second) { 342 if (m_files.begin()->second) {
343 DEBUG << "FileFeatureWriter::finish: NOTE: Closing feature file \"" 343 SVDEBUG << "FileFeatureWriter::finish: NOTE: Closing feature file \""
344 << m_files.begin()->second->fileName() << "\"" << endl; 344 << m_files.begin()->second->fileName() << "\"" << endl;
345 delete m_files.begin()->second; 345 delete m_files.begin()->second;
346 } 346 }
347 m_files.erase(m_files.begin()); 347 m_files.erase(m_files.begin());
348 } 348 }