public void UpdateFromEntry(EntryInfo entity) { this.ID = entity.ID; this.FileName = Path.GetFileNameWithoutExtension(entity.FileName); this.FileExtension = Path.GetExtension(entity.FileName).Replace(".", ""); this.FileLength = entity.FileLength; }
private static IndexNode BinaryInsertNode(IndexLink baseLink, IndexNode baseNode, EntryInfo entry, Engine engine) { IndexUnit pageIndex = engine.GetFreeIndexPage(); IndexNode newNode = pageIndex.Nodes[pageIndex.NodeIndex]; baseLink.PageID = pageIndex.UnitID; baseLink.Index = pageIndex.NodeIndex; newNode.UpdateFromEntry(entry); newNode.DataPageID = DataFactory.GetStartDataPageID(engine); if (pageIndex.UnitID != baseNode.IndexPage.UnitID) { engine.CacheIndexPage.AddPage(baseNode.IndexPage, true); } engine.CacheIndexPage.AddPage(pageIndex, true); return newNode; }
public static IndexNode BinaryInsert(EntryInfo target, IndexNode baseNode, Engine engine) { int dif = baseNode.ID.CompareTo(target.ID); if (dif == 1) { if (baseNode.Right.IsEmpty) { return BinaryInsertNode(baseNode.Right, baseNode, target, engine); } return BinaryInsert(target, GetChildIndexNode(baseNode.Right, engine), engine); } if (dif != -1) { throw new FileDBException("Same GUID?!?"); } if (baseNode.Left.IsEmpty) { return BinaryInsertNode(baseNode.Left, baseNode, target, engine); } return BinaryInsert(target, GetChildIndexNode(baseNode.Left, engine), engine); }
public EntryInfo Store(string fileName, Stream input) { EntryInfo entry = new EntryInfo(fileName); this._engine.Write(entry, input); return entry; }
internal void Store(EntryInfo entry, Stream input) { this._engine.Write(entry, input); }
public EntryInfo Save(EntryInfo i, string content) { EntryInfo rlt = null; EntryInfo info = Search(i.ID); if (info != null) { rlt = Save(i.FileName, content); Delete(i.ID); } return rlt; }
public string Load(EntryInfo entry) { MemoryStream stream = new MemoryStream(); EntryInfo info = Read(entry.ID, stream); string rlt = Encoding.Unicode.GetString(stream.ToArray()); return rlt; }
public void Write(EntryInfo entry, Stream stream) { IndexNode rootIndexNode = IndexFactory.GetRootIndexNode(this); IndexNode indexNode = IndexFactory.BinaryInsert(entry, rootIndexNode, this); DataFactory.InsertFile(indexNode, stream, this); entry.FileLength = indexNode.FileLength; indexNode.IsDeleted = false; this.Header.IsDirty = true; }
public EntryInfo Read(Guid id, Stream stream) { IndexNode indexNode = this.Search(id); if (indexNode == null) { return null; } EntryInfo entry = new EntryInfo(indexNode); DataFactory.ReadFile(indexNode, stream, this); return entry; }