public static IO FileCreateOrAppendOpen(string name) { if (IsFileExists(name)) { IO io = FileOpen(name, true); io.Seek(SeekOrigin.End, 0); return(io); } else { return(FileCreate(name)); } }
public Buf ReadHamcore(string name) { if (name[0] == '|') { name = name.Substring(1); } if (name[0] == '/' || name[0] == '\\') { name = name.Substring(1); } string filename = name; filename = filename.Replace("/", "\\"); Buf b; if (this.disableReadRawFile == false) { try { b = Buf.ReadFromFile(HamcoreDirName + "\\" + filename); return(b); } catch { } } lock (list) { HamCoreEntry c; string key = filename.ToUpper(); b = null; if (list.ContainsKey(key)) { c = list[key]; if (c.Buffer != null) { b = new Buf(c.Buffer); b.SeekToBegin(); c.LastAccess = Time.Tick64; } else { if (hamcore_io.Seek(SeekOrigin.Begin, (int)c.Offset)) { byte[] data = hamcore_io.Read((int)c.SizeCompressed); int dstSize = (int)c.Size; byte[] buffer = ZLib.Uncompress(data, dstSize); c.Buffer = buffer; b = new Buf(buffer); b.SeekToBegin(); c.LastAccess = Time.Tick64; } } } long now = Time.Tick64; foreach (HamCoreEntry cc in list.Values) { if (cc.Buffer != null) { if (((cc.LastAccess + HamcoreCacheExpires) < now) || cc.FileName.StartsWith("Li", StringComparison.CurrentCultureIgnoreCase)) { cc.Buffer = null; } } } } return(b); }