]> diplodocus.org Git - flac-archive/blob - crap.cc
ed0e01d620c184b1053655a816759ef6fa49405a
[flac-archive] / crap.cc
1 extern "C" {
2 #include <sys/types.h>
3 #include <sys/mman.h>
4 #include <sys/stat.h>
5
6 #include <fcntl.h>
7 #include <stdio.h>
8 #include <unistd.h>
9
10 };
11
12 #include <attachedpictureframe.h>
13 #include <id3v2tag.h>
14 #include <mpegfile.h>
15
16 int main(int argc, char *argv[])
17 {
18 struct stat st;
19 stat(argv[2], &st);
20 int fd = open(argv[2], O_RDONLY);
21 char *m = (char *)malloc(st.st_size);
22 read(fd, m, st.st_size);
23
24 TagLib::MPEG::File f(argv[1]);
25 TagLib::ID3v2::AttachedPictureFrame p;
26 p.setMimeType("image/jpeg");
27 p.setType(TagLib::ID3v2::AttachedPictureFrame::FrontCover);
28 TagLib::ByteVector bv;
29 bv.setData(m, st.st_size);
30 p.setPicture(bv);
31 TagLib::ID3v2::Tag *t = f.ID3v2Tag(true);
32 t->addFrame(&p);
33 f.save();
34 return 0;
35 }