本文整理汇总了C++中taglib::File::isOpen方法的典型用法代码示例。如果您正苦于以下问题:C++ File::isOpen方法的具体用法?C++ File::isOpen怎么用?C++ File::isOpen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taglib::File
的用法示例。
在下文中一共展示了File::isOpen方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeInfo
bool KMpcPlugin::writeInfo(const KFileMetaInfo& info) const
{
TagLib::File *file;
if (!TagLib::File::isWritable(QFile::encodeName(info.path()).data())) {
kDebug(7034) << "can't write to " << info.path();
return false;
}
file = new TagLib::MPC::File(QFile::encodeName(info.path()).data(), false);
if(!file->isOpen())
{
kDebug(7034) << "couldn't open " << info.path();
delete file;
return false;
}
Translator t(info);
file->tag()->setTitle(t["Title"]);
file->tag()->setArtist(t["Artist"]);
file->tag()->setAlbum(t["Album"]);
file->tag()->setYear(t.toInt("Date"));
file->tag()->setComment(t["Comment"]);
file->tag()->setTrack(t.toInt("Tracknumber"));
file->tag()->setGenre(t["Genre"]);
file->save();
delete file;
return true;
}
示例2: readInfo
bool KMpcPlugin::readInfo( KFileMetaInfo& info, uint what )
{
bool readComment = false;
bool readTech = false;
if (what & (KFileMetaInfo::Fastest |
KFileMetaInfo::DontCare |
KFileMetaInfo::ContentInfo)) readComment = true;
if (what & (KFileMetaInfo::Fastest |
KFileMetaInfo::DontCare |
KFileMetaInfo::TechnicalInfo)) readTech = true;
if ( info.path().isEmpty() ) // remote file
return false;
TagLib::File *file = new TagLib::MPC::File(QFile::encodeName(info.path()).data(), readTech);
if (!file->isOpen())
{
kDebug(7034) << "Couldn't open " << file->name();
delete file;
return false;
}
if(readComment)
{
KFileMetaInfoGroup commentgroup = appendGroup(info, "Comment");
QString date = file->tag()->year() > 0 ? QString::number(file->tag()->year()) : QString();
QString track = file->tag()->track() > 0 ? QString::number(file->tag()->track()) : QString();
appendItem(commentgroup, "Title", TStringToQString(file->tag()->title()).trimmed());
appendItem(commentgroup, "Artist", TStringToQString(file->tag()->artist()).trimmed());
appendItem(commentgroup, "Album", TStringToQString(file->tag()->album()).trimmed());
appendItem(commentgroup, "Date", date);
appendItem(commentgroup, "Comment", TStringToQString(file->tag()->comment()).trimmed());
appendItem(commentgroup, "Tracknumber", track);
appendItem(commentgroup, "Genre", TStringToQString(file->tag()->genre()).trimmed());
}
if (readTech)
{
KFileMetaInfoGroup techgroup = appendGroup(info, "Technical");
TagLib::MPC::Properties *properties =
(TagLib::MPC::Properties*)(file->audioProperties());
appendItem(techgroup, "Bitrate", properties->bitrate());
appendItem(techgroup, "Sample Rate", properties->sampleRate());
appendItem(techgroup, "Channels", properties->channels());
appendItem(techgroup, "Length", properties->length());
appendItem(techgroup, "Version", properties->mpcVersion());
}
delete file;
return true;
}
示例3: writeInfo
bool KFlacPlugin::writeInfo(const KFileMetaInfo& info) const
{
TagLib::File *file;
if (!TagLib::File::isWritable(QFile::encodeName(info.path()).data())) {
kdDebug(7034) << "can't write to " << info.path() << endl;
return false;
}
if (info.mimeType() == "audio/x-flac")
file = new TagLib::FLAC::File(QFile::encodeName(info.path()).data(), false);
#ifdef TAGLIB_1_2
else
file = new TagLib::Ogg::FLAC::File(QFile::encodeName(info.path()).data(), false);
#endif
if(!file->isOpen())
{
kdDebug(7034) << "couldn't open " << info.path() << endl;
delete file;
return false;
}
Translator t(info);
file->tag()->setTitle(t["Title"]);
file->tag()->setArtist(t["Artist"]);
file->tag()->setAlbum(t["Album"]);
file->tag()->setYear(t.toInt("Date"));
file->tag()->setComment(t["Comment"]);
file->tag()->setTrack(t.toInt("Tracknumber"));
file->tag()->setGenre(t["Genre"]);
file->save();
delete file;
return true;
}
示例4: Load
bool CTagLoaderTagLib::Load(const std::string& strFileName, CMusicInfoTag& tag, const std::string& fallbackFileExtension, MUSIC_INFO::EmbeddedArt *art /* = NULL */)
{
std::string strExtension = URIUtils::GetExtension(strFileName);
StringUtils::TrimLeft(strExtension, ".");
if (strExtension.empty())
{
strExtension = fallbackFileExtension;
if (strExtension.empty())
return false;
}
StringUtils::ToLower(strExtension);
TagLibVFSStream* stream = new TagLibVFSStream(strFileName, true);
if (!stream)
{
CLog::Log(LOGERROR, "could not create TagLib VFS stream for: %s", strFileName.c_str());
return false;
}
ID3v1::Tag::setStringHandler(&ID3v1StringHandler);
ID3v2::Tag::setLatin1StringHandler(&ID3v2StringHandler);
TagLib::File* file = NULL;
TagLib::APE::File* apeFile = NULL;
TagLib::ASF::File* asfFile = NULL;
TagLib::FLAC::File* flacFile = NULL;
TagLib::IT::File* itFile = NULL;
TagLib::Mod::File* modFile = NULL;
TagLib::MP4::File* mp4File = NULL;
TagLib::MPC::File* mpcFile = NULL;
TagLib::MPEG::File* mpegFile = NULL;
TagLib::Ogg::Vorbis::File* oggVorbisFile = NULL;
TagLib::Ogg::FLAC::File* oggFlacFile = NULL;
TagLib::S3M::File* s3mFile = NULL;
TagLib::TrueAudio::File* ttaFile = NULL;
TagLib::WavPack::File* wvFile = NULL;
TagLib::XM::File* xmFile = NULL;
TagLib::RIFF::WAV::File * wavFile = NULL;
TagLib::RIFF::AIFF::File * aiffFile = NULL;
if (strExtension == "ape")
file = apeFile = new APE::File(stream);
else if (strExtension == "asf" || strExtension == "wmv" || strExtension == "wma")
file = asfFile = new ASF::File(stream);
else if (strExtension == "flac")
file = flacFile = new FLAC::File(stream, ID3v2::FrameFactory::instance());
else if (strExtension == "it")
file = itFile = new IT::File(stream);
else if (strExtension == "mod" || strExtension == "module" || strExtension == "nst" || strExtension == "wow")
file = modFile = new Mod::File(stream);
else if (strExtension == "mp4" || strExtension == "m4a" ||
strExtension == "m4r" || strExtension == "m4b" ||
strExtension == "m4p" || strExtension == "3g2")
file = mp4File = new MP4::File(stream);
else if (strExtension == "mpc")
file = mpcFile = new MPC::File(stream);
else if (strExtension == "mp3" || strExtension == "aac")
file = mpegFile = new MPEG::File(stream, ID3v2::FrameFactory::instance());
else if (strExtension == "s3m")
file = s3mFile = new S3M::File(stream);
else if (strExtension == "tta")
file = ttaFile = new TrueAudio::File(stream, ID3v2::FrameFactory::instance());
else if (strExtension == "wv")
file = wvFile = new WavPack::File(stream);
else if (strExtension == "aif" || strExtension == "aiff")
file = aiffFile = new RIFF::AIFF::File(stream);
else if (strExtension == "wav")
file = wavFile = new RIFF::WAV::File(stream);
else if (strExtension == "xm")
file = xmFile = new XM::File(stream);
else if (strExtension == "ogg")
file = oggVorbisFile = new Ogg::Vorbis::File(stream);
else if (strExtension == "oga") // Leave this madness until last - oga container can have Vorbis or FLAC
{
file = oggFlacFile = new Ogg::FLAC::File(stream);
if (!file || !file->isValid())
{
delete file;
oggFlacFile = NULL;
file = oggVorbisFile = new Ogg::Vorbis::File(stream);
}
}
if (!file || !file->isOpen())
{
delete file;
delete stream;
CLog::Log(LOGDEBUG, "file could not be opened for tag reading");
return false;
}
APE::Tag *ape = NULL;
ASF::Tag *asf = NULL;
MP4::Tag *mp4 = NULL;
ID3v1::Tag *id3v1 = NULL;
ID3v2::Tag *id3v2 = NULL;
Ogg::XiphComment *xiph = NULL;
Tag *generic = NULL;
if (apeFile)
//.........这里部分代码省略.........