using Inspectron.Fastbuffer.Interfaces; namespace Inspectron.Fastbuffer { public class RingbufferRepository { private readonly string _path; private readonly string _goodIndexPath; private readonly string _badIndexPath; private readonly IndexFile _goodIndex; private readonly IndexFile _badIndex; public const string BufferDirectory = ".rb"; public const string GoodIndexFile = "good.idx"; public const string BadIndexFile = "bad.idx"; public RingbufferRepository(string path, int goodBufferSize, int badBufferSize, IFilesystem filesystem) { _path = path; _goodIndexPath = Path.Combine(_path, BufferDirectory, GoodIndexFile); _badIndexPath = Path.Combine(_path, BufferDirectory, BadIndexFile); Directory.CreateDirectory(Path.Combine(_path,BufferDirectory)); _goodIndex = new IndexFile(_goodIndexPath, goodBufferSize, filesystem); _badIndex = new IndexFile(_badIndexPath, badBufferSize, filesystem); var id= _goodIndex.GetCurrentArtifactId(); Console.WriteLine(@"RB size: "+id); for (int i = 0; i < 3; i++) { var artifact = _goodIndex.GetArtifactPath(i); Console.WriteLine(@"Artifact: "+artifact); } } public IndexFile GoodIndex => _goodIndex; public IndexFile BadIndex => _badIndex; public void WriteGood(byte[] data, string fileName) { _goodIndex.WriteNextArtifact(data, fileName); } public void WriteBad(byte[] data, string fileName) { _badIndex.WriteNextArtifact(data, fileName); } } }