FileSystem.BlockData.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using System.Runtime.InteropServices;
  8. namespace GameFramework.FileSystem
  9. {
  10. internal sealed partial class FileSystem : IFileSystem
  11. {
  12. /// <summary>
  13. /// 块数据。
  14. /// </summary>
  15. [StructLayout(LayoutKind.Sequential)]
  16. private struct BlockData
  17. {
  18. public static readonly BlockData Empty = new BlockData(0, 0);
  19. private readonly int m_StringIndex;
  20. private readonly int m_ClusterIndex;
  21. private readonly int m_Length;
  22. public BlockData(int clusterIndex, int length)
  23. : this(-1, clusterIndex, length)
  24. {
  25. }
  26. public BlockData(int stringIndex, int clusterIndex, int length)
  27. {
  28. m_StringIndex = stringIndex;
  29. m_ClusterIndex = clusterIndex;
  30. m_Length = length;
  31. }
  32. public bool Using
  33. {
  34. get
  35. {
  36. return m_StringIndex >= 0;
  37. }
  38. }
  39. public int StringIndex
  40. {
  41. get
  42. {
  43. return m_StringIndex;
  44. }
  45. }
  46. public int ClusterIndex
  47. {
  48. get
  49. {
  50. return m_ClusterIndex;
  51. }
  52. }
  53. public int Length
  54. {
  55. get
  56. {
  57. return m_Length;
  58. }
  59. }
  60. public BlockData Free()
  61. {
  62. return new BlockData(m_ClusterIndex, (int)GetUpBoundClusterOffset(m_Length));
  63. }
  64. }
  65. }
  66. }