public bool HasLump(BinaryStateLump lump) { string name = BinaryStateFileNames.GetReadName(lump); ZipEntry e; return(_entriesbyname.TryGetValue(name, out e)); }
public bool GetLump(BinaryStateLump lump, bool abort, Action <BinaryReader, long> callback) { return(GetLump(lump, abort, delegate(Stream s, long length) { var br = new BinaryReader(s); callback(br, length); })); }
public bool GetLump(BinaryStateLump lump, bool abort, Action <TextReader> callback) { return(GetLump(lump, abort, delegate(Stream s, long unused) { var tr = new StreamReader(s); callback(tr); })); }
static BinaryStateLump() { foreach (var prop in typeof(BinaryStateLump).GetProperties(BindingFlags.Public | BindingFlags.Static)) { var attr = prop.GetCustomAttributes(false).OfType <NameAttribute>().Single(); object value = new BinaryStateLump(attr.Name, attr.Ext); prop.SetValue(null, value, null); } }
public void PutLump(BinaryStateLump lump, Action <BinaryWriter> callback) { PutLump(lump, delegate(Stream s) { var bw = new BinaryWriter(s); callback(bw); bw.Flush(); }); }
public void PutLump(BinaryStateLump lump, Action <TextWriter> callback) { PutLump(lump, delegate(Stream s) { TextWriter tw = new StreamWriter(s); callback(tw); tw.Flush(); }); }
public void PutLump(BinaryStateLump lump, Action <Stream> callback) { var name = BinaryStateFileNames.Get(lump); var e = new ZipEntry(name); if (Global.Config.SaveStateCompressionLevelNormal == 0) { e.CompressionMethod = CompressionMethod.Stored; } else { e.CompressionMethod = CompressionMethod.Deflated; } _zip.PutNextEntry(e); callback(_zip); _zip.CloseEntry(); }
/// <param name="lump">lump to retrieve</param> /// <param name="abort">pass true to throw exception instead of returning false</param> /// <param name="callback">function to call with the desired stream</param> /// <returns>true iff stream was loaded</returns> /// <exception cref="Exception">stream not found and <paramref name="abort"/> is <see langword="true"/></exception> public bool GetLump(BinaryStateLump lump, bool abort, Action <Stream, long> callback) { if (_entriesByName.TryGetValue(lump.ReadName, out var e)) { using var zs = _zip.GetInputStream(e); callback(zs, e.Size); return(true); } if (abort) { throw new Exception($"Essential zip section not found: {lump.ReadName}"); } return(false); }
/// <summary> /// Gets a lump /// </summary> /// <param name="lump">lump to retriever</param> /// <param name="abort">true to throw exception on failure</param> /// <param name="callback">function to call with the desired stream</param> /// <returns>true if callback was called and stream was loaded</returns> public bool GetLump(BinaryStateLump lump, bool abort, Action <Stream, long> callback) { ZipEntry e; if (_entriesbyname.TryGetValue(lump.ReadName, out e)) { using (var zs = _zip.GetInputStream(e)) { callback(zs, e.Size); } return(true); } if (abort) { throw new Exception("Essential zip section not found: " + lump.ReadName); } return(false); }
/// <summary> /// Gets a lump /// </summary> /// <param name="lump">lump to retriever</param> /// <param name="abort">true to throw exception on failure</param> /// <param name="callback">function to call with the desired stream</param> /// <returns>true if callback was called and stream was loaded</returns> public bool GetLump(BinaryStateLump lump, bool abort, Action <Stream, long> callback) { var name = BinaryStateFileNames.Get(lump); var e = _zip.GetEntry(name); if (e != null) { using (var zs = _zip.GetInputStream(e)) { callback(zs, e.Size); } return(true); } if (abort) { throw new Exception("Essential zip section not found: " + name); } return(false); }
public void PutLump(BinaryStateLump lump, Action<Stream> callback) { _zip.WriteItem(lump.WriteName, callback); }
public void PutLump(BinaryStateLump lump, Action<BinaryWriter> callback) { PutLump(lump, delegate(Stream s) { var bw = new BinaryWriter(s); callback(bw); bw.Flush(); }); }
public static string Get(BinaryStateLump lump) { return(LumpNames[lump]); }
public void PutLump(BinaryStateLump lump, Action<Stream> callback) { var name = BinaryStateFileNames.Get(lump); var e = new ZipEntry(name); if (Global.Config.SaveStateCompressionLevelNormal == 0) e.CompressionMethod = CompressionMethod.Stored; else e.CompressionMethod = CompressionMethod.Deflated; _zip.PutNextEntry(e); callback(_zip); _zip.CloseEntry(); }
public static string GetReadName(BinaryStateLump lump) { return(ReadNames[lump]); }
public void PutLump(BinaryStateLump lump, Action <Stream> callback) { var name = BinaryStateFileNames.GetWriteName(lump); _zip.WriteItem(name, callback); }
/// <summary> /// Gets a lump /// </summary> /// <param name="lump">lump to retriever</param> /// <param name="abort">true to throw exception on failure</param> /// <param name="callback">function to call with the desired stream</param> /// <returns>true if callback was called and stream was loaded</returns> public bool GetLump(BinaryStateLump lump, bool abort, Action<Stream, long> callback) { var name = BinaryStateFileNames.Get(lump); var e = _zip.GetEntry(name); if (e != null) { using (var zs = _zip.GetInputStream(e)) { callback(zs, e.Size); } return true; } if (abort) { throw new Exception("Essential zip section not found: " + name); } return false; }
public IndexedStateLump(BinaryStateLump root) { _root = root; Ext = _root.Ext; Calc(); }
public static string GetWriteName(BinaryStateLump lump) { return WriteNames[lump]; }
static void AddLumpName(BinaryStateLump token, string name) { ReadNames[token] = Path.GetFileNameWithoutExtension(name); WriteNames[token] = name; }
public static string GetReadName(BinaryStateLump lump) { return ReadNames[lump]; }
public void PutLump(BinaryStateLump lump, Action<Stream> callback) { var name = BinaryStateFileNames.GetWriteName(lump); _zip.WriteItem(name, callback); }
public bool HasLump(BinaryStateLump lump) { string name = BinaryStateFileNames.GetReadName(lump); ZipEntry e; return _entriesbyname.TryGetValue(name, out e); }
public void PutLump(BinaryStateLump lump, Action<TextWriter> callback) { PutLump(lump, delegate(Stream s) { TextWriter tw = new StreamWriter(s); callback(tw); tw.Flush(); }); }
public static string GetWriteName(BinaryStateLump lump) { return(WriteNames[lump]); }
public bool HasLump(BinaryStateLump lump) { ZipEntry e; return _entriesbyname.TryGetValue(lump.ReadName, out e); }
public bool HasLump(BinaryStateLump lump) { ZipEntry e; return(_entriesbyname.TryGetValue(lump.ReadName, out e)); }
/// <summary> /// Gets a lump /// </summary> /// <param name="lump">lump to retriever</param> /// <param name="abort">true to throw exception on failure</param> /// <param name="callback">function to call with the desired stream</param> /// <returns>true if callback was called and stream was loaded</returns> public bool GetLump(BinaryStateLump lump, bool abort, Action<Stream, long> callback) { ZipEntry e; if (_entriesbyname.TryGetValue(lump.ReadName, out e)) { using (var zs = _zip.GetInputStream(e)) { callback(zs, e.Size); } return true; } if (abort) { throw new Exception("Essential zip section not found: " + lump.ReadName); } return false; }
public bool GetLump(BinaryStateLump lump, bool abort, Action<BinaryReader, long> callback) { return GetLump(lump, abort, delegate(Stream s, long length) { var br = new BinaryReader(s); callback(br, length); }); }
public void PutLump(BinaryStateLump lump, Action <Stream> callback) { _zip.WriteItem(lump.WriteName, callback); }
public bool GetLump(BinaryStateLump lump, bool abort, Action<TextReader> callback) { return GetLump(lump, abort, delegate(Stream s, long unused) { var tr = new StreamReader(s); callback(tr); }); }
static BinaryStateLump() { foreach (var prop in typeof(BinaryStateLump).GetProperties(BindingFlags.Public | BindingFlags.Static)) { var attr = prop.GetCustomAttributes(false).OfType<NameAttribute>().Single(); object value = new BinaryStateLump(attr.Name, attr.Ext); prop.SetValue(null, value, null); } }
public static string Get(BinaryStateLump lump) { return LumpNames[lump]; }