Exemple #1
0
        /// <summary>
        ///    Constructs and initializes a new instance of <see
        ///    cref="DivXTag" /> by reading the contents from a
        ///    specified position in a specified file.
        /// </summary>
        /// <param name="file">
        ///    A <see cref="File" /> object containing the file from
        ///    which the contents of the new instance is to be read.
        /// </param>
        /// <param name="position">
        ///    A <see cref="long" /> value specify at what position to
        ///    read the tag.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///    <paramref name="file" /> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///    <paramref name="position" /> is less than zero or greater
        ///    than the size of the file.
        /// </exception>
        /// <exception cref="CorruptFileException">
        ///    The file does not contain the file identifier at the
        ///    correct offset from the given position.
        /// </exception>
        public DivXTag(File file, long position)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            file.Mode = TagLibSharp.File.AccessMode.Read;

            if (position < 0 ||
                position > file.Length - Size)
            {
                throw new ArgumentOutOfRangeException(
                          "position");
            }

            file.Seek(position);

            // read the tag -- always 128 bytes

            ByteVector data = file.ReadBlock((int)Size);

            // some initial sanity checking

            if (!data.EndsWith(FileIdentifier))
            {
                throw new CorruptFileException(
                          "DivX tag data does not end with identifier.");
            }

            Parse(data);
        }
 public DivXTag(ByteVector data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (data.Count < 0x80L)
     {
         throw new CorruptFileException("DivX tag data is less than 128 bytes long.");
     }
     if (!data.EndsWith(FileIdentifier))
     {
         throw new CorruptFileException("DivX tag data does not end with identifier.");
     }
     this.Parse(data);
 }
Exemple #3
0
 public DivXTag(ByteVector data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     if (data.Count < Size)
     {
         throw new CorruptFileException("DivX tag data is less than 128 bytes long.");
     }
     if (!data.EndsWith(FileIdentifier))
     {
         throw new CorruptFileException("DivX tag data does not end with identifier.");
     }
     Parse(data);
 }
Exemple #4
0
 public void EndsWith()
 {
     Assert.IsTrue(TestVector.EndsWith("UVWXYZ"));
     Assert.IsFalse(TestVector.EndsWith("NOOP"));
 }