diff --git a/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.cpp index db9a177e..61cf6ed8 100644 --- a/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/3rdparty/taglib/mpeg/id3v2/frames/textidentificationframe.cpp @@ -339,7 +339,13 @@ UserTextIdentificationFrame::UserTextIdentificationFrame(const String &descripti String UserTextIdentificationFrame::toString() const { - return "[" + description() + "] " + fieldList().toString(); + // first entry is the description itself, drop from values list + StringList l = fieldList(); + for(StringList::Iterator it = l.begin(); it != l.end(); ++it) { + l.erase(it); + break; + } + return "[" + description() + "] " + l.toString(); } String UserTextIdentificationFrame::description() const diff --git a/3rdparty/taglib/ogg/flac/oggflacfile.cpp b/3rdparty/taglib/ogg/flac/oggflacfile.cpp index 53d04508..07ea9dcc 100644 --- a/3rdparty/taglib/ogg/flac/oggflacfile.cpp +++ b/3rdparty/taglib/ogg/flac/oggflacfile.cpp @@ -231,11 +231,21 @@ void Ogg::FLAC::File::scan() if(!metadataHeader.startsWith("fLaC")) { // FLAC 1.1.2+ + // See https://xiph.org/flac/ogg_mapping.html for the header specification. + if(metadataHeader.size() < 13) + return; + + if(metadataHeader[0] != 0x7f) + return; + if(metadataHeader.mid(1, 4) != "FLAC") return; - if(metadataHeader[5] != 1) - return; // not version 1 + if(metadataHeader[5] != 1 && metadataHeader[6] != 0) + return; // not version 1.0 + + if(metadataHeader.mid(9, 4) != "fLaC") + return; metadataHeader = metadataHeader.mid(13); } diff --git a/3rdparty/taglib/toolkit/tfilestream.cpp b/3rdparty/taglib/toolkit/tfilestream.cpp index 17a09f3d..487df8e3 100644 --- a/3rdparty/taglib/toolkit/tfilestream.cpp +++ b/3rdparty/taglib/toolkit/tfilestream.cpp @@ -58,6 +58,11 @@ namespace #endif } + FileHandle openFile(const int fileDescriptor, bool readOnly) + { + return InvalidFileHandle; + } + void closeFile(FileHandle file) { CloseHandle(file); @@ -98,6 +103,11 @@ namespace return fopen(path, readOnly ? "rb" : "rb+"); } + FileHandle openFile(const int fileDescriptor, bool readOnly) + { + return fdopen(fileDescriptor, readOnly ? "rb" : "rb+"); + } + void closeFile(FileHandle file) { fclose(file); @@ -149,13 +159,28 @@ FileStream::FileStream(FileName fileName, bool openReadOnly) d->file = openFile(fileName, true); if(d->file == InvalidFileHandle) - { # ifdef _WIN32 debug("Could not open file " + fileName.toString()); # else debug("Could not open file " + String(static_cast(d->name))); # endif - } +} + +FileStream::FileStream(int fileDescriptor, bool openReadOnly) + : d(new FileStreamPrivate("")) +{ + // First try with read / write mode, if that fails, fall back to read only. + + if(!openReadOnly) + d->file = openFile(fileDescriptor, false); + + if(d->file != InvalidFileHandle) + d->readOnly = false; + else + d->file = openFile(fileDescriptor, true); + + if(d->file == InvalidFileHandle) + debug("Could not open file using file descriptor"); } FileStream::~FileStream() @@ -255,8 +280,7 @@ void FileStream::insert(const ByteVector &data, unsigned long start, unsigned lo ByteVector buffer = data; ByteVector aboutToOverwrite(static_cast(bufferLength)); - while(true) - { + while(true) { // Seek to the current read position and read the data that we're about // to overwrite. Appropriately increment the readPosition. @@ -304,8 +328,7 @@ void FileStream::removeBlock(unsigned long start, unsigned long length) ByteVector buffer(static_cast(bufferLength)); - for(unsigned int bytesRead = -1; bytesRead != 0;) - { + for(unsigned int bytesRead = -1; bytesRead != 0;) { seek(readPosition); bytesRead = static_cast(readFile(d->file, buffer)); readPosition += bytesRead; @@ -401,7 +424,8 @@ long FileStream::tell() const const LARGE_INTEGER zero = {}; LARGE_INTEGER position; - if(SetFilePointerEx(d->file, zero, &position, FILE_CURRENT) && position.QuadPart <= LONG_MAX) { + if(SetFilePointerEx(d->file, zero, &position, FILE_CURRENT) && + position.QuadPart <= LONG_MAX) { return static_cast(position.QuadPart); } else { @@ -470,9 +494,8 @@ void FileStream::truncate(long length) #else const int error = ftruncate(fileno(d->file), length); - if(error != 0) { + if(error != 0) debug("FileStream::truncate() -- Coundn't truncate the file."); - } #endif } diff --git a/3rdparty/taglib/toolkit/tfilestream.h b/3rdparty/taglib/toolkit/tfilestream.h index 96a476d6..aa4d71b3 100644 --- a/3rdparty/taglib/toolkit/tfilestream.h +++ b/3rdparty/taglib/toolkit/tfilestream.h @@ -54,6 +54,11 @@ namespace TagLib { */ FileStream(FileName file, bool openReadOnly = false); + /*! + * Construct a File object and opens the \a file using file descriptor. + */ + FileStream(int fileDescriptor, bool openReadOnly = false); + /*! * Destroys this FileStream instance. */