//更新资源 private void DownloadNewResources() { FileManager.CreateDirectory(m_temPath); FileLoadAgent agent = new FileLoadAgent(); Dictionary <string, DownState> downloaded = new Dictionary <string, DownState>(); if (File.Exists(m_temPath + "download.list")) { ParseDownloadList(downloaded, agent); } JsonNode root = null; if (File.Exists(m_temPath + Config.BundleManifest)) { root = new JsonParser().Load(agent.Load(m_temPath + Config.BundleManifest)); if (root.IsTable()) { string ver = root["Version"].ToString(); if (ver.Equals(m_remoteVersion)) { } else { root = null; } } else { root = null; } } if (root == null) { DownLoadManifest(() => { root = new JsonParser().Load(agent.Load(m_temPath + Config.BundleManifest)); CombineDownloadList(root, downloaded); }); } else { CombineDownloadList(root, downloaded); } }
private void ParseDownloadList(Dictionary <string, DownState> downloaded, FileLoadAgent agent) { byte[] bytes = agent.Load(m_temPath + "download.list"); string str = new UTF8Encoding().GetString(bytes); string[] lines = StringUtil.Split(str, '\n'); for (int i = 0; i < lines.Length; i++) { string[] data = StringUtil.Split(lines[i], ':'); if (data.Length >= 2) { if (downloaded.ContainsKey(data[0])) { downloaded[data[0]].UpdateState(data[2]); } else { downloaded.Add(data[0], new DownState(data[1], data.Length > 2 ? data[2] : "")); } } } }