Exemplo n.º 1
0
        //安装补丁文件文件
        private int UF_install_patch_zip(string ZipFilePath)
        {
            UF_logInfo(string.Format("install_patch_zip -- begin install zipfile : {0}", ZipFilePath));

            string cachefolderPath = GlobalPath.CachePath;
            string resfolderPath   = GlobalPath.ResPersistentPath;
            string rawfolderPath   = GlobalPath.StreamingAssetsPath + "/";
            int    retcode         = 0;

            //检查zip包是否存在
            FileInfo fi = new FileInfo(ZipFilePath);

            if (!fi.Exists)
            {
                UF_logError(string.Format("install_unzip -- zip file{0} not exist! ", ZipFilePath));
                return(-103);
            }

            //解压补丁文件到缓存目录
            if (0 != (retcode = DLLImport.LLFileExtract(ZipFilePath, cachefolderPath, Handle_ExtractProgress, Handle_UnZipError)))
            {
                UF_logError(string.Format("install_unzip -- DLLImport.LLFileExtrac Failed retcode[{0}] zipfile[{1}]", retcode, ZipFilePath));
                return(retcode);
            }

            UF_logInfo("install_patch_zip -- loading version");

            //获取补丁列表处理解压出来的补丁文件
            Dictionary <string, FILE_TYPE> dicUpdatePatch = new Dictionary <string, FILE_TYPE> ();

            if (UF_wrapdicFilePatch(cachefolderPath + "res_version.txt", dicUpdatePatch) != 0)
            {
                UF_deleteCacheFolder(new DirectoryInfo(cachefolderPath));
                return(-104);
            }

            UF_logInfo("Start Patching Files");
            //处理补丁文件
            if ((UF_handlepatchfile(cachefolderPath, resfolderPath, rawfolderPath, dicUpdatePatch)) != 0)
            {
                UF_deleteCacheFolder(new DirectoryInfo(cachefolderPath));
                return(-105);
            }

            UF_deleteCacheFolder(new DirectoryInfo(cachefolderPath));

            UF_logInfo("install_patch_zip -- install game thread end");

            return(0);
        }
Exemplo n.º 2
0
        private int UF_threadInstallNet(object e)
        {
            UF_logInfo("running in thread -> threaddownLoadAndIntallzip");

            string zipName = e as string;

            if (string.IsNullOrEmpty(zipName))
            {
                UF_logError("Thread Install Failed,Zip Name is null");
            }
            string zipfilePath = GlobalPath.CachePath + zipName;
            string url_zipfile = GlobalSettings.UrlAssetsUpgrade + zipName;

            UF_logInfo(string.Format("Start Install Zip file:{0}\n{1}\n{2}\n", zipName, zipfilePath, url_zipfile));

            string cachefolderPath = GlobalSettings.UrlAssetsUpgrade;

            UF_SetUpgradeInfo(GlobalText.LAN_START_INSTALL_GAME);

            int retcode = 0;

            m_ProgressTotal  = 1;
            m_ProgressUpdate = 0;
            s_ProgresssZip   = 0;
            m_CurProgress    = 0;

            //下载base 安装包
            UF_SetUpgradeInfo(GlobalText.LAN_DOWNLOAD_GAME);
            m_UseDownloadProgress = true;
            while (true)
            {
                if (0 != (retcode = UF_downloadzipfile(url_zipfile, cachefolderPath)))
                {
                    //断点更新失败
                    if (retcode == 416)
                    {
                        if (File.Exists(zipfilePath))
                        {
                            UF_logError(string.Format("Download breakpoint continue Failed url:[{1}],try again now", retcode, url_zipfile));
                            File.Delete(zipfilePath);
                            continue;
                        }
                    }
                    else
                    {
                        UF_logError(string.Format("Download zipfile Failed retcode:[{0}]  url:[{1}]", retcode, url_zipfile));
                        break;
                    }
                }
                break;
            }
            //下载成功,进行安装
            UF_SetUpgradeInfo(GlobalText.LAN_INSTALL_GAME);
            m_UseDownloadProgress = false;
            m_ProgressTotal       = 1;
            m_ProgressUpdate      = 0;
            s_ProgresssZip        = 0;
            m_CurProgress         = 0;

            //解压安装 文件
            retcode = DLLImport.LLFileExtract(zipfilePath, GlobalPath.ResPersistentPath, Handle_ExtractProgress, Handle_UnZipError);

#if !UNITY_EDITOR && UNITY_ANDROID
            //清空cache 中的安装文件
            System.IO.FileInfo zipfi = new System.IO.FileInfo(zipfilePath);
            if (zipfi.Exists)
            {
                zipfi.Delete();
            }
            UF_logInfo("Clean Install file in Cache");
#endif

            if (retcode != 0)
            {
                UF_logError(string.Format("AppDLLImport.FileExtract Failed [{0}] \n{1}\n{2}", retcode, zipfilePath, GlobalPath.ResPersistentPath));
            }

            m_CurProgress = 1;

            return(retcode);
        }
Exemplo n.º 3
0
        //zip 的安装方式
        private int UF_threadInstallBase(object e)
        {
            UF_logInfo("running in thread -> threadInstallzip");

            string zipName = e as string;

            if (string.IsNullOrEmpty(zipName))
            {
                UF_logError("Thread Install Failed,Zip Name is null");
            }

            UF_logInfo(string.Format("Start Install Zip file:{0}", zipName));

            string zipfilePath = GlobalPath.CachePath + zipName;

            string cachefolderPath = GlobalPath.CachePath;

            UF_SetUpgradeInfo(GlobalText.LAN_START_INSTALL_GAME);
            int retcode = 0;

            m_ProgressTotal  = 1;
            m_ProgressUpdate = 0;
            s_ProgresssZip   = 0;
            m_CurProgress    = 0;

                        #if UNITY_EDITOR || UNITY_STANDALONE || UNITY_IPHONE
            zipfilePath = GlobalPath.StreamingAssetsPath + "/" + zipName;
#elif UNITY_ANDROID
            string apkPath     = GlobalPath.AppPath;
            string packageName = "assets/" + zipName;
            zipfilePath = cachefolderPath + zipName;
            UF_logInfo(string.Format("Extract Base File[{0}] Zip file Form: {1} \n To: {2}", packageName, apkPath, cachefolderPath));
            //解压apK中的安装文件到cache目录
            retcode = DLLImport.LLSpecifiedFileExtract(apkPath, packageName, cachefolderPath);
            if (retcode != 0)
            {
                UF_logError(string.Format("DLLImport.LLSpecifiedFileExtract Failed [{0}] \n{1}\n{2}\n{3}", retcode, apkPath, packageName, cachefolderPath));
                return(retcode);
            }
            UF_logInfo("Extract Install zip to Cache");
#endif
            UF_SetUpgradeInfo(GlobalText.LAN_INSTALL_GAME);

            //解压安装 文件
            retcode = DLLImport.LLFileExtract(zipfilePath, GlobalPath.ResPersistentPath, Handle_ExtractProgress, Handle_UnZipError);

                        #if !UNITY_EDITOR && UNITY_ANDROID
            //清空cache 中的安装文件
            System.IO.FileInfo zipfi = new System.IO.FileInfo(zipfilePath);
            if (zipfi.Exists)
            {
                zipfi.Delete();
            }
            UF_logInfo("Clean Install file in Cache");
                        #endif

            if (retcode != 0)
            {
                UF_logError(string.Format("DLLImport.FileExtract Failed [{0}] \n{1}\n{2}", retcode, zipfilePath, GlobalPath.ResPersistentPath));
            }

            s_ProgresssZip = 1;

            return(retcode);
        }