コード例 #1
0
 public void ParseVersionList()
 {
     if (!IsVersionFileExist)
     {
         Debug.LogFormat("<color=#FFFF33> 检测不到version文件:{0} ,需要从服务器更新</color>", VersionFilePath);
         return;
     }
     VersionInfoList = ABHelper.ReadVersionFile(VersionFilePath);
 }
コード例 #2
0
        public string GetAbRelativePath(string abPath)
        {
            if (null == VersionInfoList)
            {
                VersionInfoList = ABHelper.ReadVersionFile(VersionFilePath);
            }

            string abRelativePath = "";

            abPath = abPath.ToLower();

            List <string> abVerInfo = null;

            VersionInfoList.TryGetValue(abPath, out abVerInfo);
            if (null != abVerInfo && int.Parse(abVerInfo[1]) > ABVersion.OriginalVersionId.Id3rd)
            {
                abRelativePath = string.Format("{0}/{1}", abVerInfo[1], abVerInfo[3]);
            }
            return(abRelativePath);
        }
コード例 #3
0
ファイル: ABPacker.cs プロジェクト: mengtest/TAccumulation
        private static void CreatVersionTxt()
        {
            // 版号文件
            string fileUrl = CreatFileUrlMd5(ABHelper.VersionNumFileName);

            ABHelper.WriteVersionNumFile(CurVersionABExportPath + fileUrl, ABHelper.VersionNumCombine(TheVersionNum[0], TheVersionNum[1], CurVersionNum.ToString(), TheVersionNum[3]));
            // ab的依赖文件
            fileUrl = CreatFileUrlMd5(ABHelper.ManifestFileName);
            ABHelper.WriteManifestFile(CurVersionABExportPath + fileUrl, ResFolder, CurVersionManifestList);
            // 创建版本文件
            CurVersionList = ABHelper.ReadVersionFile(PlatformABExportPath + "/" + (CurVersionNum - 1) + "/" + ABHelper.VersionFileName);
            List <string> filePaths = ABHelper.GetAllFilesPathInDir(CurVersionABExportPath);

            foreach (string path in filePaths)
            {
                if (path.EndsWith(".manifest"))
                {
                    continue;
                }
                string path2 = path.Replace("\\", "/").Replace(CurVersionABExportPath, "").ToLower();
                if (path2.Equals(CurVersionNum.ToString()) || path2.Equals(ABHelper.DependFileName) || path2.Equals(ABHelper.Md5FileName))
                {
                    continue;
                }

                string value = CurVersionFileUrlMd5[path2].ToLower();
                if (CurVersionList.ContainsKey(value))
                {
                    CurVersionList.Remove(value);
                }
                CurVersionList.Add(value, new List <string>()
                {
                    ABHelper.BuildMD5ByFile(path), CurVersionNum.ToString(), ABHelper.FileSize(path).ToString(), path2
                });
            }
            ABHelper.WriteVersionFile(CurVersionABExportPath + ABHelper.VersionFileName, CurVersionList);
        }
コード例 #4
0
ファイル: ABPacker.cs プロジェクト: mengtest/TAccumulation
        private static void CreatHotterZip(int preVersionNum)
        {
            if (preVersionNum == CurVersionNum || preVersionNum < int.Parse(TheVersionNum[2]))
            {
                return;
            }
            Debug.Log("Update Version From :" + preVersionNum + " to " + CurVersionNum);

            Dictionary <string, List <string> > preVersionMd5 = ABHelper.ReadVersionFile(PlatformABExportPath + "/" + preVersionNum.ToString() + "/" + ABHelper.VersionFileName);

            // 需要更新的文件
            Dictionary <string, string> updateFiles = new Dictionary <string, string>();

            foreach (KeyValuePair <string, List <string> > pair in CurVersionList)
            {
                string        path       = pair.Key;
                string        md5        = pair.Value[0];
                string        verId      = pair.Value[1];
                string        name       = pair.Value[3];
                List <string> oldMd5Info = null;
                if (preVersionMd5.TryGetValue(path, out oldMd5Info))
                {
                    if (oldMd5Info[0] != md5 || oldMd5Info[1] != verId)
                    {
                        updateFiles.Add(name, verId);
                    }
                }
                else
                {
                    updateFiles.Add(name, verId);
                }
            }
            // version添加进来
            if (File.Exists(CurVersionABExportPath + ABHelper.VersionFileName) && !updateFiles.ContainsKey(ABHelper.VersionFileName))
            {
                updateFiles.Add(ABHelper.VersionFileName, CurVersionNum.ToString());
            }

            // 生成更新文件夹
            string zipFolder = ABExportHotterZipPath + preVersionNum + "-" + CurVersionNum;

            if (Directory.Exists(zipFolder))
            {
                Directory.Delete(zipFolder, true);
            }
            Directory.CreateDirectory(zipFolder);

            // 复制到更新文件夹下
            foreach (var fileInfo in updateFiles)
            {
                string sourceFile = PlatformABExportPath + "/" + fileInfo.Value + "/" + fileInfo.Key;
                string copyFile   = zipFolder + "/" + fileInfo.Value + "/" + fileInfo.Key;
                if (File.Exists(copyFile))
                {
                    File.Delete(copyFile);
                }
                string copyPath = Path.GetDirectoryName(copyFile);
                if (!Directory.Exists(copyPath))
                {
                    Directory.CreateDirectory(copyPath);
                }
                // 资源拷贝
                File.Copy(sourceFile, copyFile, true);
            }

            // 压缩
            string zipFullName = zipFolder + ".zip";

            zipFolder = zipFolder.Replace("\\", "/");
            DirectoryInfo sourzeZipFolder = new DirectoryInfo(zipFolder);

            FastZipEvents zipEvents = new FastZipEvents();

            zipEvents.DirectoryFailure = DirectoryFailureHandler;
            zipEvents.FileFailure      = FileFailureHandler;
            zipEvents.Progress         = ProgressHandler;

            // 压缩前的文件大小
            filePreSize = 0;
            fileZipSize = 0;
            foreach (var path in ABHelper.GetAllFilesPathInDir(sourzeZipFolder.FullName))
            {
                FileInfo fileInfo = new FileInfo(path);
                filePreSize += fileInfo.Length;
            }

            // 进行压缩
            ZipSuccess = true;
            ABHelper.ZipFile(zipFullName, sourzeZipFolder.FullName, zipEvents);
            while (!ZipSuccess)
            {
                ZipSuccess = true;
                ABHelper.ZipFile(zipFullName, sourzeZipFolder.FullName, zipEvents);
            }
            EditorUtility.ClearProgressBar();

            // 压缩后的文件大小
            // 1-2.ini
            FileInfo zipfile = new FileInfo(zipFullName);

            ABHelper.WriteFile(zipFolder + ".ini", ("zipsize:" + zipfile.Length + ":" + filePreSize));
        }