- Initial commit

This commit is contained in:
Timur Kozanov
2026-07-03 05:02:26 +03:00
commit 374ff1e689
4080 changed files with 388870 additions and 0 deletions

View File

@ -0,0 +1,42 @@
using System;
using System.IO;
using Best.HTTP.Shared.Databases.Utils;
namespace Best.HTTP.Shared.Databases
{
public abstract class Metadata
{
public int Index;
public int FilePosition;
public int Length;
public bool IsDeleted => this.FilePosition == -1 && this.Length == -1;
public void MarkForDelete()
{
this.FilePosition = -1;
this.Length = -1;
}
public virtual void SaveTo(Stream stream)
{
if (this.IsDeleted)
throw new Exception($"Trying to save a deleted metadata({this.ToString()})!");
stream.EncodeUnsignedVariableByteInteger((uint)this.FilePosition);
stream.EncodeUnsignedVariableByteInteger((uint)this.Length);
}
public virtual void LoadFrom(Stream stream)
{
this.FilePosition = (int)stream.DecodeUnsignedVariableByteInteger();
this.Length = (int)stream.DecodeUnsignedVariableByteInteger();
}
public override string ToString()
{
return $"[Metadata Idx: {Index}, Pos: {FilePosition}, Length: {Length}, IsDeleted: {IsDeleted}]";
}
}
}