Mercurial > hg > svcore
comparison transform/FileFeatureWriter.cpp @ 1428:87ae75da6527
Convert some cerrs to SVCERRs. Apart from anything else, this makes MSVC2017 happy
author | Chris Cannam |
---|---|
date | Thu, 01 Mar 2018 14:43:40 +0000 |
parents | c7f1300dbf64 |
children | 70e172e6cc59 |
comparison
equal
deleted
inserted
replaced
1427:622d193a00dc | 1428:87ae75da6527 |
---|---|
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 cerr << "FileFeatureWriter::FileFeatureWriter: ERROR: Invalid support specification " << support << endl; | 49 SVCERR << "FileFeatureWriter::FileFeatureWriter: ERROR: Invalid support specification " << support << endl; |
50 } | 50 } |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 FileFeatureWriter::~FileFeatureWriter() | 54 FileFeatureWriter::~FileFeatureWriter() |
128 m_baseDir = i->second.c_str(); | 128 m_baseDir = i->second.c_str(); |
129 } else if (i->first == "many-files") { | 129 } else if (i->first == "many-files") { |
130 if (m_support & SupportOneFilePerTrackTransform && | 130 if (m_support & SupportOneFilePerTrackTransform && |
131 m_support & SupportOneFilePerTrack) { | 131 m_support & SupportOneFilePerTrack) { |
132 if (m_singleFileName != "") { | 132 if (m_singleFileName != "") { |
133 cerr << "FileFeatureWriter::setParameters: WARNING: Both one-file and many-files parameters provided, ignoring many-files" << endl; | 133 SVCERR << "FileFeatureWriter::setParameters: WARNING: Both one-file and many-files parameters provided, ignoring many-files" << endl; |
134 } else { | 134 } else { |
135 m_manyFiles = true; | 135 m_manyFiles = true; |
136 } | 136 } |
137 } | 137 } |
138 } else if (i->first == "one-file") { | 138 } else if (i->first == "one-file") { |
142 // may be on by default (for any FileFeatureWriter | 142 // may be on by default (for any FileFeatureWriter |
143 // that supports OneFilePerTrackTransform but not | 143 // that supports OneFilePerTrackTransform but not |
144 // OneFilePerTrack), so we need to be able to | 144 // OneFilePerTrack), so we need to be able to |
145 // override it | 145 // override it |
146 // if (m_manyFiles) { | 146 // if (m_manyFiles) { |
147 // cerr << "FileFeatureWriter::setParameters: WARNING: Both many-files and one-file parameters provided, ignoring one-file" << endl; | 147 // SVCERR << "FileFeatureWriter::setParameters: WARNING: Both many-files and one-file parameters provided, ignoring one-file" << endl; |
148 // } else { | 148 // } else { |
149 m_singleFileName = i->second.c_str(); | 149 m_singleFileName = i->second.c_str(); |
150 // } | 150 // } |
151 } | 151 } |
152 } | 152 } |
153 } else if (i->first == "stdout") { | 153 } else if (i->first == "stdout") { |
154 if (m_support & SupportStdOut) { | 154 if (m_support & SupportStdOut) { |
155 if (m_singleFileName != "") { | 155 if (m_singleFileName != "") { |
156 cerr << "FileFeatureWriter::setParameters: WARNING: Both stdout and one-file provided, ignoring stdout" << endl; | 156 SVCERR << "FileFeatureWriter::setParameters: WARNING: Both stdout and one-file provided, ignoring stdout" << endl; |
157 } else { | 157 } else { |
158 m_stdout = true; | 158 m_stdout = true; |
159 } | 159 } |
160 } | 160 } |
161 } else if (i->first == "append") { | 161 } else if (i->first == "append") { |
170 FileFeatureWriter::createOutputFilename(QString trackId, | 170 FileFeatureWriter::createOutputFilename(QString trackId, |
171 TransformId transformId) | 171 TransformId transformId) |
172 { | 172 { |
173 if (m_singleFileName != "") { | 173 if (m_singleFileName != "") { |
174 if (QFileInfo(m_singleFileName).exists() && !(m_force || m_append)) { | 174 if (QFileInfo(m_singleFileName).exists() && !(m_force || m_append)) { |
175 cerr << endl << "FileFeatureWriter: ERROR: Specified output file \"" << m_singleFileName << "\" exists and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append flag is specified -- not overwriting" << endl; | 175 SVCERR << endl << "FileFeatureWriter: ERROR: Specified output file \"" << m_singleFileName << "\" exists and neither --" << getWriterTag() << "-force nor --" << getWriterTag() << "-append flag is specified -- not overwriting" << endl; |
176 cerr << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl; | 176 SVCERR << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl; |
177 return ""; | 177 return ""; |
178 } | 178 } |
179 return m_singleFileName; | 179 return m_singleFileName; |
180 } | 180 } |
181 | 181 |
217 filename.replace(':', '_'); // ':' not permitted in Windows | 217 filename.replace(':', '_'); // ':' not permitted in Windows |
218 | 218 |
219 filename = QDir(dirname).filePath(filename); | 219 filename = QDir(dirname).filePath(filename); |
220 | 220 |
221 if (QFileInfo(filename).exists() && !(m_force || m_append)) { | 221 if (QFileInfo(filename).exists() && !(m_force || m_append)) { |
222 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; | 222 SVCERR << 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; |
223 cerr << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl; | 223 SVCERR << "NOTE: To find out how to fix this problem, read the help for the --" << getWriterTag() << "-force" << endl << "and --" << getWriterTag() << "-append options" << endl; |
224 return ""; | 224 return ""; |
225 } | 225 } |
226 | 226 |
227 return filename; | 227 return filename; |
228 } | 228 } |
298 QFile *file = new QFile(filename); | 298 QFile *file = new QFile(filename); |
299 QIODevice::OpenMode mode = (QIODevice::WriteOnly); | 299 QIODevice::OpenMode mode = (QIODevice::WriteOnly); |
300 if (m_append) mode |= QIODevice::Append; | 300 if (m_append) mode |= QIODevice::Append; |
301 | 301 |
302 if (!file->open(mode)) { | 302 if (!file->open(mode)) { |
303 cerr << "FileFeatureWriter: ERROR: Failed to open output file \"" << filename | 303 SVCERR << "FileFeatureWriter: ERROR: Failed to open output file \"" << filename |
304 << "\" for writing" << endl; | 304 << "\" for writing" << endl; |
305 delete file; | 305 delete file; |
306 m_files[key] = 0; | 306 m_files[key] = 0; |
307 throw FailedToOpenFile(filename); | 307 throw FailedToOpenFile(filename); |
308 } | 308 } |