Example #1
0
 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;
 }
Example #2
0
 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;
 }
Example #3
0
 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);
 }
Example #4
0
 public EntryInfo Store(string fileName, Stream input)
 {
     EntryInfo entry = new EntryInfo(fileName);
     this._engine.Write(entry, input);
     return entry;
 }
Example #5
0
 internal void Store(EntryInfo entry, Stream input)
 {
     this._engine.Write(entry, input);
 }
Example #6
0
		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;
		}
Example #7
0
		public string Load(EntryInfo entry)
		{
			MemoryStream stream = new MemoryStream();
			EntryInfo info = Read(entry.ID, stream);
			string rlt = Encoding.Unicode.GetString(stream.ToArray());
			return rlt;
		}
Example #8
0
 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;
 }
Example #9
0
 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;
 }