示例#1
0
        /// <summary>
        ///    Looks for a tag ending at a specified position and moves
        ///    the cursor to its start position.
        /// </summary>
        /// <param name="position">
        ///    A <see cref="long" /> value reference specifying at what
        ///    position the potential tag starts. If a tag is found,
        ///    this value will be updated to the position at which the
        ///    found tag ends.
        /// </param>
        /// <returns>
        ///    A <see cref="TagLib.TagTypes" /> value specifying the
        ///    type of tag found at the specified position, or <see
        ///    cref="TagTypes.None" /> if no tag was found.
        /// </returns>
        private TagTypes ReadTagInfo(ref long position)
        {
            file.Seek(position);
            ByteVector data = file.ReadBlock(read_size);

            try {
                if (data.StartsWith(TagLib.Ape.Footer.FileIdentifier))
                {
                    TagLib.Ape.Footer footer =
                        new TagLib.Ape.Footer(data);

                    position += footer.CompleteTagSize;
                    return(TagTypes.Ape);
                }

                if (data.StartsWith(TagLib.Id3v2.Header.FileIdentifier))
                {
                    TagLib.Id3v2.Header header =
                        new TagLib.Id3v2.Header(data);

                    position += header.CompleteTagSize;
                    return(TagTypes.Id3v2);
                }
            } catch (CorruptFileException) {
            }

            return(TagTypes.None);
        }
示例#2
0
        /// <summary>
        ///    Looks for a tag starting at a specified position and moves
        ///    the cursor to its start position.
        /// </summary>
        /// <param name="position">
        ///    A <see cref="long" /> value reference specifying at what
        ///    position the potential tag starts. If a tag is found,
        ///    this value will be updated to the position at which the
        ///    found tag ends.
        /// </param>
        /// <returns>
        ///    A <see cref="TagLib.TagTypes" /> value specifying the
        ///    type of tag found at the specified position, or <see
        ///    cref="TagTypes.None" /> if no tag was found.
        /// </returns>
        private TagTypes ReadTagInfo(ref long position)
        {
            file.Seek (position);
            ByteVector data = file.ReadBlock (read_size);

            try {
                if (data.StartsWith (TagLib.Ape.Footer.FileIdentifier)) {
                    TagLib.Ape.Footer footer =
                        new TagLib.Ape.Footer (data);

                    position += footer.CompleteTagSize;
                    return TagTypes.Ape;
                }

                if (data.StartsWith (TagLib.Id3v2.Header.FileIdentifier)) {
                    TagLib.Id3v2.Header header =
                        new TagLib.Id3v2.Header (data);

                    position += header.CompleteTagSize;
                    return TagTypes.Id3v2;
                }
            } catch (CorruptFileException) {
            }

            return TagTypes.None;
        }