public static FileListCompareAll Compare(string newPath, string oldPath) { if (string.IsNullOrEmpty(newPath) || string.IsNullOrEmpty(oldPath)) { return(null); } if (!File.Exists(newPath) || !File.Exists(oldPath)) { return(null); } FileList newFileList = ReadFileList(newPath); FileList oldFileList = ReadFileList(oldPath); //FileList newFileList = BuildCommon.ReadJsonFromFile<FileList>(newPath); //FileList oldFileList = BuildCommon.ReadJsonFromFile<FileList>(oldPath); if (newFileList == null) { Debug.LogErrorFormat("{0} Load Failed!", newPath); return(null); } if (oldFileList == null) { Debug.LogErrorFormat("{0} Load Failed!", oldPath); return(null); } FileListCompareAll compareall = new FileListCompareAll(); compareall.time = System.DateTime.Now.ToString(); compareall.newFileList = string.Format("{0} : {1}", newPath, MD5Utils.GetMD5(newPath)); compareall.oldFileList = string.Format("{0} : {1}", oldPath, MD5Utils.GetMD5(oldPath)); for (int i = 1; i < (int)BundleUpdateMode.Update_End; i++) { BundleUpdateMode mode = (BundleUpdateMode)i; FileListCompareData comData = FileList.Compare(newFileList, oldFileList, true, mode); if (comData == null) { continue; } FileListCompareInfo info = new FileListCompareInfo(); info.mode = mode.ToString(); info.data = comData; compareall.infoList.Add(info); } return(compareall); }
public static string CompareFileList(BundleUpdateMode mode = BundleUpdateMode.Update_CRC) { string old_FileListPath = string.Format("{0}/{1}", ResourceConst.BundleFolder, ResourceConst.FileListName); string new_fileListPath = string.Format("{0}/{1}", PackAssetBundle.bundleBuildFolder, ResourceConst.FileListName); if (!File.Exists(new_fileListPath) || !File.Exists(old_FileListPath)) { return("1"); } FileList new_fileList = PackBundleTools.GetAssetBundleFileList(new_fileListPath); FileList old_fileList = PackBundleTools.GetAssetBundleFileList(old_FileListPath); if (new_fileList == null || old_fileList == null) { return("2"); } FileListCompareData compareData = FileList.Compare(new_fileList, old_fileList, true, mode); if (compareData == null) { return("3"); } string update_size = Size2String(compareData.add_size + compareData.modifiy_size); string add_size = Size2String(compareData.add_size); string mod_size = Size2String(compareData.modifiy_size); string del_size = Size2String(compareData.delete_size); string strInfo = string.Format("本地打包较上次需要更新{0}({1})", update_size, mode); strInfo = string.Format("{0}\n其中:\n增加:{1}", strInfo, add_size); strInfo = string.Format("{0}\n改变:{1}", strInfo, mod_size); strInfo = string.Format("{0}\n删除:{1}", strInfo, del_size); return(strInfo); }
public static bool Equals(BundleUpdateMode mode, BundleInfo left, BundleInfo right) { if (left == null || right == null) { return(true); } switch (mode) { case BundleUpdateMode.Update_CRC: return(left.crc == right.crc); case BundleUpdateMode.Update_MD5: return(string.Equals(left.md5, right.md5)); case BundleUpdateMode.Update_CRCANDMD5: return(left.crc == right.crc || string.Equals(left.md5, right.md5)); case BundleUpdateMode.Update_CRCORMD5: return(left.crc == right.crc && string.Equals(left.md5, right.md5)); } return(true); }
public static FileListCompareData Compare(FileList newFileList, FileList oldFileList, bool remove_old = true, BundleUpdateMode mode = BundleUpdateMode.Update_CRC) { FileListCompareData comData = new FileListCompareData(); if (newFileList == null) { return(comData); } if (oldFileList == null) { comData.addList.CopyFrom(newFileList.m_FileList); return(comData); } for (int i = 0; i < newFileList.m_FileList.Count; i++) { BundleInfo bundleInfo = newFileList.m_FileList[i]; if (bundleInfo == null || string.IsNullOrEmpty(bundleInfo.bundleName)) { continue; } BundleInfo oldBundleInfo = oldFileList.GetBundleInfo(bundleInfo.bundleName); if (oldBundleInfo == null) { comData.addList.Add(bundleInfo); continue; } if (BundleInfo.Equals(mode, oldBundleInfo, bundleInfo)) { continue; } //if (oldBundleInfo.crc == bundleInfo.crc) //{ // continue; //} comData.modifiyList.Add(bundleInfo); } if (remove_old) { return(comData); } for (int i = 0; i < oldFileList.m_FileList.Count; i++) { BundleInfo oldBundleInfo = oldFileList.m_FileList[i]; if (oldBundleInfo == null || string.IsNullOrEmpty(oldBundleInfo.bundleName)) { continue; } BundleInfo bundleInfo = newFileList.GetBundleInfo(oldBundleInfo.bundleName); if (bundleInfo != null) { continue; } comData.deleteList.Add(bundleInfo); } return(comData); }