| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace System.Fire.Container {
- public partial class ContainerList {
- private string _containerName;
- private string _path;
- private DateTime loadDuration = new DateTime(0);
- private DateTime saveDuration = new DateTime(0);
- /// <summary>
- /// Get the container list name
- /// </summary>
- public string ContainerName {
- get {
- return this._containerName;
- }
- set {
- this._containerName = value;
- }
- }
- /// <summary>
- /// Get or set the path of the container
- /// When setting a new path, it will load the container automaticly
- /// </summary>
- public string Path {
- get {
- return this._path;
- }
- set {
- if (value != this.Path) {
- this.Save();
- this.ChunkFile.Close();
- this.InfoFile.Close();
- this.Load(value);
- }
- }
- }
- /// <summary>
- /// Get the number of files that are stored in the containers
- /// </summary>
- public int NumFiles {
- get {
- return this._files.Count();
- }
- }
- /// <summary>
- /// Get the max possible container size in bytes, the container list may have, depending on all set containers and empty containers
- /// </summary>
- public ulong PossibleContainerListSize {
- get {
- ulong filledContainers = 0;
- int numEmptyContainers = 0;
- numEmptyContainers += (256 - this._container.Count) * 256;
- for(int i = 0; i < this._container.Count;i++) {
- numEmptyContainers += 256 - this._container[i].Count;
- for (int j = 0; j < this._container[i].Count;j++) {
- filledContainers += (ulong)this._container[i][j].ChunkSize;
- }
- }
- return filledContainers + (ulong)(numEmptyContainers * this._maxContainerSize);
- }
- }
- /// <summary>
- /// Get the size of all containers
- /// </summary>
- public long Size {
- get {
- long tmp = 0;
- for (int i = 0, c1 = this._container.Count; i < c1; i++)
- for (int j = 0, c2 = this._container[i].Count; j < c2; j++)
- tmp += this._container[i][j].ContainerSize;
- return tmp;
- }
- }
- /// <summary>
- /// Get the number of containers
- /// </summary>
- public int NumContainers {
- get {
- int tmp = 0;
- for (int i = 0, c1 = this._container.Count; i < c1; i++)
- tmp += this._container.Count;
- return tmp;
- }
- }
- /// <summary>
- /// Get the number of container groups
- /// </summary>
- public int NumGroups {
- get {
- return this._container.Count;
- }
- }
- /// <summary>
- /// Returns the duration the container list needed to load
- /// </summary>
- public DateTime LoadDuration {
- get {
- return this.loadDuration;
- }
- }
- /// <summary>
- /// Returns the duration the container list needed to save
- /// </summary>
- public DateTime SaveDuration {
- get {
- return this.saveDuration;
- }
- }
- }
- }
|