protected bool ExtractAndWriteDownFile(string compressDir, string destDir, string fileName, byte[] data) { //write to file bool bRet = AssetBundleUtil.WriteToFile(compressDir, fileName, data); if (!bRet) { m_error = String.Format("WriteToFile: {0} failed", compressDir + fileName); return(false); } //解压缩文件 string compressFilePath = compressDir + fileName; int ret = DodLibUtil.GetDodLib().Decompress7zip(compressFilePath, destDir); if (ret != 1) { BLogger.Error("doDecompress7zip failed: {0}, Ret:{1}", compressFilePath, ret); m_error = StartupTextConfigMgr.Instance.GetText(StartupTextDefine.ID_STARTUP_UPDATE_EXTRACT_DOWNFILE_FAILED, fileName, ret); return(false); } //删除压缩文件 AssetBundleUtil.DeleteFile(compressFilePath); return(true); }
private byte[] LoadStreamAsset(string path) { var fullPath = Application.streamingAssetsPath + "/" + path; byte[] data = null; if (fullPath.Contains("://")) { if (!DPlatform.IsEditorPlatform() && DPlatform.IsAndroidPlatform()) { data = DodLibUtil.GetDodLib().LoadStreamAssetFile(fullPath); } } else { data = AssetBundleUtil.ReadFile(fullPath); } return(data); }
public bool Init() { if (m_inited) { return(true); } //清除错误 m_error = null; string configFileName = "Config.bytes"; string platformName = DodLibUtil.GetDodLib().GetPlatformName(); if (!string.IsNullOrEmpty(platformName)) { configFileName = string.Format("Config_{0}.bytes", platformName); } var configData = LoadStreamAsset(configFileName); if (configData == null) { BLogger.Error("read config.bytes failed"); return(false); } var jsonText = System.Text.Encoding.UTF8.GetString(configData); if (!BaseConfigInfo.Init(platformName, jsonText, ref m_error)) { return(false); } if (!ParseLocalConfig(jsonText)) { BLogger.Error("ParseLocalConfig failed"); return(false); } m_inited = true; return(true); }