HeaderBlock.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //*******************************
  2. // Created By Rocher Kong
  3. // Github https://github.com/RocherKong
  4. // Date 2018.02.09
  5. //*******************************
  6. namespace IP2Region.Models
  7. {
  8. internal class HeaderBlock
  9. {
  10. public long IndexStartIp
  11. {
  12. get;
  13. private set;
  14. }
  15. public int IndexPtr
  16. {
  17. get;
  18. private set;
  19. }
  20. public HeaderBlock(long indexStartIp, int indexPtr)
  21. {
  22. IndexStartIp = indexStartIp;
  23. IndexPtr = indexPtr;
  24. }
  25. /// <summary>
  26. /// Get the bytes for total storage
  27. /// </summary>
  28. /// <returns>
  29. /// Bytes gotten.
  30. /// </returns>
  31. public byte[] GetBytes()
  32. {
  33. /*
  34. * +------------+-----------+
  35. * | 4bytes | 4bytes |
  36. * +------------+-----------+
  37. * start ip index ptr
  38. */
  39. byte[] b = new byte[8];
  40. Utils.WriteIntLong(b, 0, IndexStartIp);
  41. Utils.WriteIntLong(b, 4, IndexPtr);
  42. return b;
  43. }
  44. }
  45. }