ContainerList_Properties.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7. namespace System.Fire.Container {
  8. public partial class ContainerList {
  9. private string _containerName;
  10. private string _path;
  11. private DateTime loadDuration = new DateTime(0);
  12. private DateTime saveDuration = new DateTime(0);
  13. /// <summary>
  14. /// Get the container list name
  15. /// </summary>
  16. public string ContainerName {
  17. get {
  18. return this._containerName;
  19. }
  20. set {
  21. this._containerName = value;
  22. }
  23. }
  24. /// <summary>
  25. /// Get or set the path of the container
  26. /// When setting a new path, it will load the container automaticly
  27. /// </summary>
  28. public string Path {
  29. get {
  30. return this._path;
  31. }
  32. set {
  33. if (value != this.Path) {
  34. this.Save();
  35. this.ChunkFile.Close();
  36. this.InfoFile.Close();
  37. this.Load(value);
  38. }
  39. }
  40. }
  41. /// <summary>
  42. /// Get the number of files that are stored in the containers
  43. /// </summary>
  44. public int NumFiles {
  45. get {
  46. return this._files.Count();
  47. }
  48. }
  49. /// <summary>
  50. /// Get the max possible container size in bytes, the container list may have, depending on all set containers and empty containers
  51. /// </summary>
  52. public ulong PossibleContainerListSize {
  53. get {
  54. ulong filledContainers = 0;
  55. int numEmptyContainers = 0;
  56. numEmptyContainers += (256 - this._container.Count) * 256;
  57. for(int i = 0; i < this._container.Count;i++) {
  58. numEmptyContainers += 256 - this._container[i].Count;
  59. for (int j = 0; j < this._container[i].Count;j++) {
  60. filledContainers += (ulong)this._container[i][j].ChunkSize;
  61. }
  62. }
  63. return filledContainers + (ulong)(numEmptyContainers * this._maxContainerSize);
  64. }
  65. }
  66. /// <summary>
  67. /// Get the size of all containers
  68. /// </summary>
  69. public long Size {
  70. get {
  71. long tmp = 0;
  72. for (int i = 0, c1 = this._container.Count; i < c1; i++)
  73. for (int j = 0, c2 = this._container[i].Count; j < c2; j++)
  74. tmp += this._container[i][j].ContainerSize;
  75. return tmp;
  76. }
  77. }
  78. /// <summary>
  79. /// Get the number of containers
  80. /// </summary>
  81. public int NumContainers {
  82. get {
  83. int tmp = 0;
  84. for (int i = 0, c1 = this._container.Count; i < c1; i++)
  85. tmp += this._container.Count;
  86. return tmp;
  87. }
  88. }
  89. /// <summary>
  90. /// Get the number of container groups
  91. /// </summary>
  92. public int NumGroups {
  93. get {
  94. return this._container.Count;
  95. }
  96. }
  97. /// <summary>
  98. /// Returns the duration the container list needed to load
  99. /// </summary>
  100. public DateTime LoadDuration {
  101. get {
  102. return this.loadDuration;
  103. }
  104. }
  105. /// <summary>
  106. /// Returns the duration the container list needed to save
  107. /// </summary>
  108. public DateTime SaveDuration {
  109. get {
  110. return this.saveDuration;
  111. }
  112. }
  113. }
  114. }