Enable FileRef to detect file types by the actual content of a stream.

FileRef doesn't work with ByteVectorStream as reported at #796, since ByteVectorStream is not associated with a file name and FileRef detects file types based on file extensions.
This commit makes FileRef to work with ByteVectorStream by enabling it to detect file types based on the actual content of a stream.
This commit is contained in:
Tsuda Kageyu
2017-02-03 17:52:27 +09:00
parent a5d9e49c49
commit 931bb042c3
35 changed files with 613 additions and 120 deletions

View File

@ -71,6 +71,18 @@ public:
Properties *properties;
};
////////////////////////////////////////////////////////////////////////////////
// static members
////////////////////////////////////////////////////////////////////////////////
bool WavPack::File::isValidStream(IOStream *stream)
{
// A WavPack file has to start with "wvpk".
const ByteVector id = Utils::readHeader(stream, 4, false);
return (id == "wvpk");
}
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////

View File

@ -200,6 +200,14 @@ namespace TagLib {
*/
bool hasAPETag() const;
/*!
* Check if the given \a stream can be opened as a WavPack file.
*
* \note This method is designed to do a quick check. The result may
* not necessarily be correct.
*/
static bool isValidStream(IOStream *stream);
private:
File(const File &);
File &operator=(const File &);