private static List <string> CompareDiffList(ResListFile oldFileList, ResListFile newFileList) { if (newFileList == null) { return(null); } List <string> ret = null; if (oldFileList == null) { var infos = newFileList.AllToDiffInfos(); if (infos == null || infos.Length <= 0) { return(ret); } for (int i = 0; i < infos.Length; ++i) { var info = infos[i]; if (string.IsNullOrEmpty(info.fileName) || string.IsNullOrEmpty(info.fileContentMd5)) { continue; } if (ret == null) { ret = new List <string>(); } // 更新的文件都是以MD5为文件名的 ret.Add(info.fileContentMd5); } } else { var iter = newFileList.GetIter(); while (iter.MoveNext()) { string oldMd5 = oldFileList.GetFileContentMd5(iter.Current.Key); if (string.Compare(oldMd5, iter.Current.Value.fileContentMd5) != 0) { if (string.IsNullOrEmpty(iter.Current.Value.fileContentMd5)) { continue; } if (ret == null) { ret = new List <string>(); } ret.Add(iter.Current.Value.fileContentMd5); } } iter.Dispose(); } return(ret); }
public ResDiffInfo[] GetDiffInfos(ResListFile otherFile) { ResDiffInfo[] ret = null; if (otherFile != null) { /* * string writePath = Utils.FilePathMgr.Instance.WritePath; * if (string.IsNullOrEmpty(writePath)) * return ret; */ Dictionary <string, ResInfo> .Enumerator otherIter = otherFile.GetIter(); List <ResDiffInfo> diffList = new List <ResDiffInfo>(); while (otherIter.MoveNext()) { bool isDiff = false; string srcMd5 = GetFileContentMd5(otherIter.Current.Key); if (!string.IsNullOrEmpty(srcMd5)) { if (string.Compare(srcMd5, otherIter.Current.Value.fileContentMd5, StringComparison.CurrentCultureIgnoreCase) != 0) { isDiff = true; } /* * else * { * string fileName = string.Format("{0}/{1}", writePath, otherIter.Current.Key); * if (!File.Exists(fileName)) * { * isDiff = true; * } * }*/ } else { isDiff = true; } if (isDiff) { ResDiffInfo diffInfo = new ResDiffInfo(); diffInfo.fileName = otherIter.Current.Key; diffInfo.fileContentMd5 = otherIter.Current.Value.fileContentMd5; diffInfo.fileSize = otherIter.Current.Value.fileSize; diffList.Add(diffInfo); } } otherIter.Dispose(); ret = diffList.ToArray(); } return(ret); }
public void Load(ResListFile other) { Clear(); var iter = other.GetIter(); while (iter.MoveNext()) { m_FileMd5Map.Add(iter.Current.Key, iter.Current.Value); m_ContentMd5ToNameMd5Map.Add(iter.Current.Value.fileContentMd5, iter.Current.Key); } iter.Dispose(); }
public void Load(ResListFile listFile) { Clear(); if (listFile == null) { return; } var iter = listFile.GetIter(); while (iter.MoveNext()) { AutoUpdateCfgItem item = new AutoUpdateCfgItem(); item.fileContentMd5 = iter.Current.Value.fileContentMd5; item.isDone = false; item.readBytes = 0; AddOrSet(item); } iter.Dispose(); }