예제 #1
0
        internal RiffChunk(RiffList @base, Stream source, long loadOffset)
        {
            IsWriting = false;
            IsOpen    = false;
            _baseList = @base;

            BaseStream = source;

            var b = new byte[4];

            _localOffset = loadOffset;

            if ((loadOffset & 1) != 0)
            {
                throw new InvalidDataException("Chunk offset is ODD!");
            }

            source.Seek(loadOffset, SeekOrigin.Begin);

            source.Read(b, 0, 4);
            _chunkId = "" + (char)b[0] + (char)b[1] + (char)b[2] + (char)b[3];

            source.Read(b, 0, 4);
            _length = (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0];

            if (_baseList != null)
            {
                _baseList.Capture();
            }
            IsOpen = true;
        }
예제 #2
0
        internal RiffChunk(RiffList @base, Stream target, String id)
        {
            IsOpen    = false;
            IsWriting = true;
            _baseList = @base;

            if (_chunkId.Length != 4)
            {
                throw new ArgumentException("chunkId must be 4 characters in length");
            }

            BaseStream   = target;
            _localOffset = (uint)target.Position;

            if ((_localOffset & 1) != 0)
            {
                throw new InvalidDataException("Chunk offset is ODD!");
            }

            _chunkId = id;

            target.WriteByte((byte)_chunkId[0]);
            target.WriteByte((byte)_chunkId[1]);
            target.WriteByte((byte)_chunkId[2]);
            target.WriteByte((byte)_chunkId[3]);
            target.WriteByte(0);
            target.WriteByte(0);
            target.WriteByte(0);
            target.WriteByte(0);

            if (_baseList != null)
            {
                _baseList.Capture();
            }
            IsOpen = true;
        }