public void GetFileDetail(string path, out int offset, out int size, out bool encrypt) { offset = -1; size = 0; encrypt = false; Example.Combineinfo info = GetCombineInfo(path); if (info == null) { return; } offset = GetRealOffset(info); size = info.Size; encrypt = info.Encrypt; }
public byte[] Read(string path) { Example.Combineinfo info = GetCombineInfo(path); if (info == null) { return(null); } if (info.Size <= 0) { return(null); } if (fileStream != null) { byte[] data = new byte[info.Size]; int offset = GetRealOffset(info); fileStream.Read(data, offset, info.Size); if (info.Encrypt) { ResLoader.RemoveImpurity(data, null, false); } return(data); } else { IResourceFileStream fs = ResLoader.LoadFileStreamByName(name); if (fs == null) { return(null); } byte[] data = new byte[info.Size]; int offset = GetRealOffset(info); fs.Read(data, offset, info.Size); if (info.Encrypt) { ResLoader.RemoveImpurity(data, null, false); } return(data); } }
public void CollectAllFilePath(List <string> lst) { if (fileDic == null) { InitHeader(); } if (_combinefiles != null) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); for (int i = 0, count = _combinefiles.Files.Count; i < count; i++) { Example.Groupcombine gc = _combinefiles.Groups[i]; for (int j = 0, jcount = gc.Infos.Count; j < jcount; j++) { Example.Combineinfo info = gc.Infos[j]; sb.Append(_combinefiles.Dirs[info.Dir]); sb.Append(_combinefiles.Files[i]); lst.Add(sb.ToString()); } } } }
private int GetRealOffset(Example.Combineinfo info) { return(dataOffset + info.Start); }
private Example.Combineinfo GetCombineInfo(string path) { if (fileDic == null) { InitHeader(); } if (fileDic == null) { return(null); } string fileName = Path.GetFileName(path); Example.Groupcombine group; if (!fileDic.TryGetValue(fileName, out group)) { return(null); } Example.Combineinfo info = null; if (group.Infos.Count > 1) { string filePath = GetDirectoryPath(path); Example.Combineinfo ci = null; string dir = null; float simlarValue = -1; float tempSimlarValue; for (int i = 0, count = group.Infos.Count; i < count; i++) { ci = group.Infos[i]; if (ci.Dir < 0 || ci.Dir >= _combinefiles.Dirs.Count) { continue; } dir = _combinefiles.Dirs[ci.Dir].Value; if (IsSimilarPath(dir, filePath, out tempSimlarValue)) { if (tempSimlarValue > simlarValue) { info = ci; simlarValue = tempSimlarValue; } else if (simlarValue != 0 && tempSimlarValue == simlarValue) { if (info != null) { Debugger.LogError("asset error: check is simplar path has same simlar value->" + _combinefiles.Dirs[info.Dir].Value + "^" + dir + "^" + filePath + "^" + fileName + "^" + path); Debugger.LogError("------simlar path count->" + group.Infos.Count); for (int j = 0, jcount = group.Infos.Count; j < jcount; j++) { ci = group.Infos[j]; if (ci.Dir < 0 || ci.Dir >= _combinefiles.Dirs.Count) { continue; } Debugger.LogError("------simlar path->" + j + "^" + _combinefiles.Dirs[ci.Dir].Value); } } else { Debugger.LogError("asset error: check is simplar path has same simlar value info is null->" + dir + "^" + filePath + "^" + fileName + "^" + path); } } } } } else if (group.Infos.Count == 1) { info = group.Infos[0]; } if (info == null) { if (UnityEngine.Application.platform == UnityEngine.RuntimePlatform.WindowsEditor) { Example.Groupcombine gcf; if (fileDic.TryGetValue(fileName, out gcf)) { string str = null; for (int i = 0, count = gcf.Infos.Count; i < count; i++) { str += _combinefiles.Dirs[gcf.Infos[i].Dir].Value + "^"; } UnityEngine.Debug.LogError("combine exception file->" + path + "^" + fileName + ": " + str); } } return(null); } return(info); }