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);
    }
Example #2
0
    public ResDiffInfo[] AllToDiffInfos()
    {
        List <ResDiffInfo> list = new List <ResDiffInfo>();
        var iter = m_FileMd5Map.GetEnumerator();

        while (iter.MoveNext())
        {
            ResDiffInfo info = new ResDiffInfo();
            info.fileContentMd5 = iter.Current.Value.fileContentMd5;
            info.fileName       = iter.Current.Key;
            list.Add(info);
        }
        iter.Dispose();
        return(list.ToArray());
    }
    public bool FileToDiffInfo(string fileName, out ResDiffInfo[] diff)
    {
        diff = null;
        if (string.IsNullOrEmpty(fileName))
        {
            return(false);
        }

        ResInfo info;

        if (!m_FileMd5Map.TryGetValue(fileName, out info))
        {
            return(false);
        }

        diff    = new ResDiffInfo[1];
        diff[0] = new ResDiffInfo();
        diff[0].fileContentMd5 = info.fileContentMd5;
        diff[0].fileName       = fileName;
        diff[0].fileSize       = info.fileSize;

        return(true);
    }