view FileTableEntry.cs @ 5:ec77b60e5369 default tip

Re #121: Migrate to AGPL license * Update all Army Builder API files to AGPL license * Include AGPL license and remove GPL/LGPL documents
author IBBoard <dev@ibboard.co.uk>
date Sat, 15 Aug 2009 10:51:59 +0000
parents 1a5205612b72
children
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 and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING 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;
				}
			}
		}
	}
}