mirror of
https://github.com/taglib/taglib.git
synced 2026-02-12 11:12:58 -05:00
Clean up attachments
Avoid use of raw pointers.
This commit is contained in:
@ -56,17 +56,17 @@ int main(int argc, char *argv[])
|
||||
if(attachments) {
|
||||
const TagLib::Matroska::Attachments::AttachedFileList &list = attachments->attachedFileList();
|
||||
printf("Found %u attachment(s)\n", list.size());
|
||||
for(auto attachedFile : list) {
|
||||
PRINT_PRETTY("Filename", attachedFile->fileName().toCString(true));
|
||||
const TagLib::String &description = attachedFile->description();
|
||||
for(const auto &attachedFile : list) {
|
||||
PRINT_PRETTY("Filename", attachedFile.fileName().toCString(true));
|
||||
const TagLib::String &description = attachedFile.description();
|
||||
PRINT_PRETTY("Description", !description.isEmpty() ? description.toCString(true) : "None");
|
||||
const TagLib::String &mediaType = attachedFile->mediaType();
|
||||
const TagLib::String &mediaType = attachedFile.mediaType();
|
||||
PRINT_PRETTY("Media Type", !mediaType.isEmpty() ? mediaType.toCString(false) : "None");
|
||||
PRINT_PRETTY("Data Size",
|
||||
TagLib::Utils::formatString("%u byte(s)",attachedFile->data().size()).toCString(false)
|
||||
TagLib::Utils::formatString("%u byte(s)",attachedFile.data().size()).toCString(false)
|
||||
);
|
||||
PRINT_PRETTY("UID",
|
||||
TagLib::Utils::formatString("%llu",attachedFile->uid()).toCString(false)
|
||||
TagLib::Utils::formatString("%llu",attachedFile.uid()).toCString(false)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,11 +41,11 @@ int main(int argc, char *argv[])
|
||||
TagLib::FileStream image(argv[2]);
|
||||
auto data = image.readBlock(image.length());
|
||||
auto attachments = file.attachments(true);
|
||||
auto attachedFile = new TagLib::Matroska::AttachedFile();
|
||||
attachedFile->setFileName("cover.jpg");
|
||||
attachedFile->setMediaType("image/jpeg");
|
||||
attachedFile->setData(data);
|
||||
//attachedFile->setUID(5081000385627515072ull);
|
||||
TagLib::Matroska::AttachedFile attachedFile;
|
||||
attachedFile.setFileName("cover.jpg");
|
||||
attachedFile.setMediaType("image/jpeg");
|
||||
attachedFile.setData(data);
|
||||
//attachedFile.setUID(5081000385627515072ull);
|
||||
attachments->addAttachedFile(attachedFile);
|
||||
|
||||
file.save();
|
||||
|
||||
Reference in New Issue
Block a user