VerifyElement.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.IO;
  2. namespace YooAsset
  3. {
  4. /// <summary>
  5. /// 缓存文件验证元素
  6. /// </summary>
  7. internal class VerifyCacheFileElement
  8. {
  9. public string PackageName { private set; get; }
  10. public string CacheGUID { private set; get; }
  11. public string FileRootPath { private set; get; }
  12. public string DataFilePath { private set; get; }
  13. public string InfoFilePath { private set; get; }
  14. public EVerifyResult Result;
  15. public string DataFileCRC;
  16. public long DataFileSize;
  17. public VerifyCacheFileElement(string packageName, string cacheGUID, string fileRootPath, string dataFilePath, string infoFilePath)
  18. {
  19. PackageName = packageName;
  20. CacheGUID = cacheGUID;
  21. FileRootPath = fileRootPath;
  22. DataFilePath = dataFilePath;
  23. InfoFilePath = infoFilePath;
  24. }
  25. public void DeleteFiles()
  26. {
  27. try
  28. {
  29. Directory.Delete(FileRootPath, true);
  30. }
  31. catch (System.Exception e)
  32. {
  33. YooLogger.Warning($"Failed delete cache bundle folder : {e}");
  34. }
  35. }
  36. }
  37. /// <summary>
  38. /// 下载文件验证元素
  39. /// </summary>
  40. internal class VerifyTempFileElement
  41. {
  42. public string TempDataFilePath { private set; get; }
  43. public string FileCRC { private set; get; }
  44. public long FileSize { private set; get; }
  45. public int Result = 0; // 注意:原子操作对象
  46. public VerifyTempFileElement(string tempDataFilePath, string fileCRC, long fileSize)
  47. {
  48. TempDataFilePath = tempDataFilePath;
  49. FileCRC = fileCRC;
  50. FileSize = fileSize;
  51. }
  52. }
  53. }