예제 #1
0
 static void CompareStatisitics(FileListCompareData comData)
 {
     if (comData == null)
     {
         return;
     }
 }
예제 #2
0
    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);
    }
예제 #3
0
    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);
    }
예제 #4
0
    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);
    }