AssetMD5Info.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. namespace hirdParty.DownloadSystem
  4. {
  5. [Serializable]
  6. public class AssetMD5Info
  7. {
  8. public List<MD5FileInfo> fileInfo;
  9. public void Deduplication()
  10. {
  11. if (fileInfo == null)
  12. {
  13. return;
  14. }
  15. List<string> allName = new List<string>();
  16. for (int i = 0; i < fileInfo.Count; i++)
  17. {
  18. string n = fileInfo[i].fileName;
  19. if (allName.Contains(n))
  20. {
  21. fileInfo.RemoveAt(i);
  22. i--;
  23. }
  24. allName.Add(n);
  25. }
  26. }
  27. public void Sort()
  28. {
  29. if (fileInfo == null)
  30. {
  31. return;
  32. }
  33. fileInfo.Sort(Stot);
  34. }
  35. private int Stot(MD5FileInfo a, MD5FileInfo b)
  36. {
  37. if (a.size > b.size)
  38. {
  39. return 1;
  40. }
  41. else if (a.size < b.size)
  42. {
  43. return -1;
  44. }
  45. return 0;
  46. }
  47. public AssetMD5Info(List<MD5FileInfo> a)
  48. {
  49. this.fileInfo = a;
  50. }
  51. }
  52. [Serializable]
  53. public class MD5FileInfo
  54. {
  55. public string fileName;
  56. public string md5;
  57. public long size;
  58. }
  59. }