Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 4
0
 public EntryInfo Store(string fileName, Stream input)
 {
     EntryInfo entry = new EntryInfo(fileName);
     this._engine.Write(entry, input);
     return entry;
 }
Ejemplo n.º 5
0
 internal void Store(EntryInfo entry, Stream input)
 {
     this._engine.Write(entry, input);
 }
Ejemplo n.º 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;
		}
Ejemplo n.º 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;
		}
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }