/// <summary> /// </summary> /// <param name="fileName"></param> /// <param name="wasInfo"></param> public SpWas(string fileName, WasInfo wasInfo) { if (!File.Exists(fileName)) { throw new FileNotFoundException(fileName); } _fileName = fileName; _wasInfo = wasInfo; }
/// <summary> /// 加载wdf 资源 /// </summary> public override void Load() { if (_loaded) { return; } Logger.Info($"Begin Load Wdf : {FileName}"); var buffer4 = new byte[4]; try { using (var fs = new FileStream(FileName, FileMode.Open)) { fs.Read(buffer4, 0, 4); _flag = BitConverter.ToString(buffer4); fs.Read(buffer4, 0, 4); _wasFileCount = BitConverter.ToInt32(buffer4, 0); fs.Read(buffer4, 0, 4); _offset = BitConverter.ToInt32(buffer4, 0); Logger.Info($"Flag(50-46-44-57):{_flag},WasFileCount:{_wasFileCount},Offset:{_offset}"); if (string.Equals(_flag, "50-46-44-57")) { fs.Seek(_offset, SeekOrigin.Begin); // 读取文件列表 for (int i = 0; i < _wasFileCount; i++) { fs.Read(buffer4, 0, 4); int uid = BitConverter.ToInt32(buffer4, 0); fs.Read(buffer4, 0, 4); int offset = BitConverter.ToInt32(buffer4, 0); fs.Read(buffer4, 0, 4); int size = BitConverter.ToInt32(buffer4, 0); fs.Read(buffer4, 0, 4); int space = BitConverter.ToInt32(buffer4, 0); var wasInfo = new WasInfo(uid, offset, size, space); // Logger.Debug($"Was({uid}):Size:{size},Offset:{offset},Space:{space}"); _wasInfos[uid] = wasInfo; } } else { _wasFileCount = 0; } } _loaded = true; } catch (Exception e) { Logger.Error($"Error In Load Wdf : {FileName}", e); throw; } Logger.Info($"End Load Wdf : {FileName}"); }