コード例 #1
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);
    }
コード例 #2
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);
    }