public void Close() { if (fileStream != null) { fileStream.Close(); fileStream = null; } }
public bool Open() { if (fileStream != null) { return(true); } fileStream = ResLoader.LoadFileStreamByName(name); return(fileStream != null); }
private void InitHeader() { if (_initHeader) { return; } _initHeader = true; IResourceFileStream irs = ResLoader.LoadFileStreamByName(name); if (irs == null) { if (Config.Debug_Log()) { Debugger.LogError("ERROR: ivnalid combine file name->" + name); } return; } byte[] dataArr = new byte[4]; irs.Read(dataArr, 0, 4); MemoryStream ms = new MemoryStream(dataArr); BinaryReader br = new BinaryReader(ms); int headlen = br.ReadInt32(); dataOffset = 4 + headlen; dataArr = new byte[headlen]; irs.Read(dataArr, 4, headlen); irs.Close(); ms = new MemoryStream(dataArr); _combinefiles = Example.Combinefiles.Deserialize(ms); if (_combinefiles != null) { fileDic = new Dictionary <string, Example.Groupcombine>(); for (int i = 0, count = _combinefiles.Files.Count; i < count; i++) { fileDic.Add(_combinefiles.Files[i].Value, _combinefiles.Groups[i]); } _combinefiles.Files.Clear(); _combinefiles.Groups.Clear(); } }
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); } }