diff options
author | Tsuda Kageyu <tsuda.kageyu@gmail.com> | 2017-06-12 13:04:15 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-12 13:04:15 +0900 |
commit | 1fb310ec1fec60b9d6f8aae641905d1cd95b2069 (patch) | |
tree | 9116c154bdf832d5743139818cf6f66663a17796 /taglib/asf | |
parent | c8bcd153fe4a1c9c792dd8cd404226b19a3fc1c7 (diff) | |
parent | c2fe93c12b70f3ae5604564558144282af1e48c2 (diff) |
Merge pull request #799 from TsudaKageyu/filetype-detection
Enable FileRef to detect file types by the actual content of a stream.
Diffstat (limited to 'taglib/asf')
-rw-r--r-- | taglib/asf/asffile.cpp | 13 | ||||
-rw-r--r-- | taglib/asf/asffile.h | 9 |
2 files changed, 22 insertions, 0 deletions
diff --git a/taglib/asf/asffile.cpp b/taglib/asf/asffile.cpp index 8f395265..d5a80bca 100644 --- a/taglib/asf/asffile.cpp +++ b/taglib/asf/asffile.cpp @@ -27,6 +27,7 @@ #include <tbytevectorlist.h> #include <tpropertymap.h> #include <tstring.h> +#include <tagutils.h> #include "asffile.h" #include "asftag.h" @@ -474,6 +475,18 @@ void ASF::File::FilePrivate::CodecListObject::parse(ASF::File *file, unsigned in } //////////////////////////////////////////////////////////////////////////////// +// static members +//////////////////////////////////////////////////////////////////////////////// + +bool ASF::File::isSupported(IOStream *stream) +{ + // An ASF file has to start with the designated GUID. + + const ByteVector id = Utils::readHeader(stream, 16, false); + return (id == headerGuid); +} + +//////////////////////////////////////////////////////////////////////////////// // public members //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/asf/asffile.h b/taglib/asf/asffile.h index b674da79..05cf4ee2 100644 --- a/taglib/asf/asffile.h +++ b/taglib/asf/asffile.h @@ -115,6 +115,15 @@ namespace TagLib { */ virtual bool save(); + /*! + * Returns whether or not the given \a stream can be opened as an ASF + * file. + * + * \note This method is designed to do a quick check. The result may + * not necessarily be correct. + */ + static bool isSupported(IOStream *stream); + private: void read(); |