view FileTableEntry.cs @ 1:1c19230d568d

Fixes #76 - Duplicate file table entries * Add a "doesn't contain" check to adding file entries
author IBBoard <dev@ibboard.co.uk>
date Sun, 19 Apr 2009 11:38:29 +0000
parents 1a5205612b72
children ec77b60e5369
line wrap: on
line source

//  This file (FileTableEntry.cs) is a part of the IBBoard.ArmyBuilder.API project and is copyright 2009 IBBoard
// 
//  The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
// 

using System;
using System.IO;

namespace IBBoard.ArmyBuilder.API
{
	public class FileTableEntry
	{
		private ABFile parent;
		private string name = "";
		private byte[] firstBytes = new byte[8];
		private int fileSize;
		private int compressedSize;
		private byte[] midBytes = new byte[4];
		private int location;
		private byte[] endBytes = new byte[8];		
		
		public FileTableEntry(String fileName)
		{
			name = fileName;
		}

		public ABFile ParentFile
		{
			get { return parent; }
			set {
				if (parent!=value)
				{
					if (parent!=null)
					{
						parent.RemoveFileTableEntry(this);
					}
					
					parent = value;

					if (parent!=null)
					{
						parent.AddFileTableEntry(this);
					}
				}
			}
		}

		public string FileName
		{
			get { return name; }
		}

		public int FileSize
		{
			get { return fileSize; }
			set { fileSize = value; }
		}

		public FileStream GetParentFileStream()
		{
			return (parent == null ? null : parent.GetFileStream());
		}

		public int CompressedSize
		{
			get { return compressedSize; }
			set { compressedSize = value; }
		}

		public int Location
		{
			get { return location; }
			set { location = value; }
		}		

		public byte[] FirstBytes
		{
			get { return firstBytes; }
			set
			{
				if (value!=null && value.Length == 8)
				{
					firstBytes = value;
				}
			}
		}

		public byte[] MidBytes
		{
			get { return midBytes; }
			set
			{
				if (value!=null && value.Length == 4)
				{
					midBytes = value;
				}
			}
		}

		public byte[] EndBytes
		{
			get { return endBytes; }
			set
			{
				if (value!=null && value.Length == 8)
				{
					endBytes = value;
				}
			}
		}
	}
}