Exemple #1
0
		/// <summary>
		///     Add new a BLF chunk to the chunk table
		/// </summary>
		/// <param name="magic">The magic (has to be 4 chars long)</param>
		/// <param name="flags">The flags of the file (If you don't know what this is, just set it to 0)</param>
		/// <param name="content">The content of the BLF Chunk</param>
		/// <param name="chunkToInsertAfter">The BLF chunk to insert the new chunk after</param>
		public void AddBLFChunk(string magic, Int32 flags, byte[] content, BLFChunk chunkToInsertAfter)
		{
			var chunk = new BLFChunk();
			chunk.ChunkMagic = magic;
			chunk.ChunkFlags = flags;
			chunk.ChunkData = content;
			chunk.ChunkLength = content.Length + 0x0C;
			chunk.ChunkMagicIdent = Convert.ToInt32(magic);

			// Checks
			if (chunk.ChunkMagic.Length != 4)
				throw new Exception("Chunk Magic has to be 4 chars long");

			if (_blfChunks[_blfChunks.Count] == chunkToInsertAfter)
				throw new Exception("You can't insert a chunk after the header, you nub.");

			int index = 1;
			foreach (BLFChunk chunkk in _blfChunks)
				if (chunkk == chunkToInsertAfter)
					break;
				else
					index++;

			// Add chunk
			_blfChunks.Insert(index, chunk);

			RefreshRelativeChunkData();
		}
Exemple #2
0
        /// <summary>
        ///     Load the chunks in the BLF Table
        /// </summary>
        public void LoadChunkTable()
        {
            _blfChunks = new List <BLFChunk>();
            _blfStream.SeekTo(0x00);

            bool continueLoading = true;

            while (continueLoading)
            {
                if (_blfStream.Position >= _blfStream.Length)
                {
                    continueLoading = false;
                }
                else
                {
                    var chunk = new BLFChunk();

                    chunk.ChunkMagic = _blfStream.ReadAscii(0x04);
                    _blfStream.SeekTo(_blfStream.Position - 0x04);
                    chunk.ChunkMagicIdent = _blfStream.ReadInt32();

                    chunk.ChunkLength = _blfStream.ReadInt32();
                    chunk.ChunkFlags  = _blfStream.ReadInt32();

                    chunk.ChunkData = _blfStream.ReadBlock(chunk.ChunkLength - 0x0C);

                    _blfChunks.Add(chunk);
                }
            }
        }
Exemple #3
0
        /// <summary>
        ///     Add new a BLF chunk to the chunk table
        /// </summary>
        /// <param name="magic">The magic (has to be 4 chars long)</param>
        /// <param name="flags">The flags of the file (If you don't know what this is, just set it to 0)</param>
        /// <param name="content">The content of the BLF Chunk</param>
        /// <param name="chunkIndex">The index of the chunk to insert the new chunk behind</param>
        public void AddBLFChunk(string magic, Int32 flags, byte[] content, int chunkIndex)
        {
            try
            {
                BLFChunk chunk = _blfChunks[chunkIndex];

                AddBLFChunk(magic, flags, content, chunk);
            }
            catch
            {
                throw new Exception("Chunk doesn't exist bro.");
            }
        }
Exemple #4
0
        /// <summary>
        ///     Add new a BLF chunk to the chunk table
        /// </summary>
        /// <param name="magic">The magic (has to be 4 chars long)</param>
        /// <param name="flags">The flags of the file (If you don't know what this is, just set it to 0)</param>
        /// <param name="content">The content of the BLF Chunk</param>
        /// <param name="chunkToInsertAfter">The BLF chunk to insert the new chunk after</param>
        public void AddBLFChunk(string magic, Int32 flags, byte[] content, BLFChunk chunkToInsertAfter)
        {
            var chunk = new BLFChunk();

            chunk.ChunkMagic      = magic;
            chunk.ChunkFlags      = flags;
            chunk.ChunkData       = content;
            chunk.ChunkLength     = content.Length + 0x0C;
            chunk.ChunkMagicIdent = Convert.ToInt32(magic);

            // Checks
            if (chunk.ChunkMagic.Length != 4)
            {
                throw new Exception("Chunk Magic has to be 4 chars long");
            }

            if (_blfChunks[_blfChunks.Count] == chunkToInsertAfter)
            {
                throw new Exception("You can't insert a chunk after the header, you nub.");
            }

            int index = 1;

            foreach (BLFChunk chunkk in _blfChunks)
            {
                if (chunkk == chunkToInsertAfter)
                {
                    break;
                }
                else
                {
                    index++;
                }
            }

            // Add chunk
            _blfChunks.Insert(index, chunk);

            RefreshRelativeChunkData();
        }
Exemple #5
0
		/// <summary>
		///     Load the chunks in the BLF Table
		/// </summary>
		public void LoadChunkTable()
		{
			_blfChunks = new List<BLFChunk>();
			_blfStream.SeekTo(0x00);

			bool continueLoading = true;
			while (continueLoading)
			{
				if (_blfStream.Position >= _blfStream.Length)
					continueLoading = false;
				else
				{
					var chunk = new BLFChunk();

					chunk.ChunkMagic = _blfStream.ReadAscii(0x04);
					_blfStream.SeekTo(_blfStream.Position - 0x04);
					chunk.ChunkMagicIdent = _blfStream.ReadInt32();

					chunk.ChunkLength = _blfStream.ReadInt32();
					chunk.ChunkFlags = _blfStream.ReadInt32();

					chunk.ChunkData = _blfStream.ReadBlock(chunk.ChunkLength - 0x0C);

					_blfChunks.Add(chunk);
				}
			}
		}