don't crash if taglib cannot open file

This commit is contained in:
Robin Gareus 2015-07-28 00:44:50 +02:00
parent ab4263bff9
commit 2a0365cbef

View File

@ -43,6 +43,16 @@ bool
AudiofileTagger::tag_file (std::string const & filename, SessionMetadata const & metadata)
{
TagLib::FileRef file (filename.c_str());
if (file.isNull()) {
std::cerr << "TagLib::FileRef is null for file" << filename << std::endl;
return true; // continue anyway?!
}
if (!file.tag()) {
std::cerr << "TagLib::Tag is null for file" << filename << std::endl;
return true; // continue anyway?!
}
TagLib::Tag & tag (*file.tag());
tag_generic (tag, metadata);