From 9ca7b0c33a4d823f178361cf1ac2ff403905caf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= Date: Fri, 8 Feb 2019 11:39:06 +0100 Subject: [PATCH] fileref: Use user defined resolvers on streams Since the resolve only use the filename, there is no reason not to probe them, as a filename might be available through the IOStream interface. When using a ByteVectorStream, the filename will be empty and user defined resolvers won't be probed. --- taglib/fileref.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index 935c371b..ba8f4f59 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -27,6 +27,8 @@ * http://www.mozilla.org/MPL/ * ***************************************************************************/ +#include + #include #include #include @@ -65,6 +67,8 @@ namespace File *detectByResolvers(FileName fileName, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) { + if(::strlen(fileName) == 0) + return 0; ResolverList::ConstIterator it = fileTypeResolvers.begin(); for(; it != fileTypeResolvers.end(); ++it) { File *file = (*it)->createFile(fileName, readAudioProperties, audioPropertiesStyle); @@ -460,7 +464,11 @@ void FileRef::parse(FileName fileName, bool readAudioProperties, void FileRef::parse(IOStream *stream, bool readAudioProperties, AudioProperties::ReadStyle audioPropertiesStyle) { - // User-defined resolvers won't work with a stream. + // Try user-defined resolvers. + + d->file = detectByResolvers(stream->name(), readAudioProperties, audioPropertiesStyle); + if(d->file) + return; // Try to resolve file types based on the file extension.