untested because, oh look, i never submitted any build rules!
#include <sys/stat.h>
+#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
(TagLib::ID3v2::AttachedPictureFrame *)(*it);
TagLib::ByteVector data = frame->picture();
int fd = open(argv[2], O_CREAT | O_WRONLY);
- write(fd, data.data(), data.size());
- close(fd);
+ ssize_t size = data.size();
+ ssize_t status = write(fd, data.data(), size);
+ if (status < 0) {
+ perror("write");
+ return 2;
+ }
+ if (status != size) {
+ fprintf(stderr, "wrote only %d bytes out of %d\n", status, size);
+ return 3;
+ }
+ if (close(fd) < 0) {
+ perror("close");
+ }
}
return 0;