using Inspectron.Fastbuffer.Interfaces;
using OpenCvSharp;
using Serilog;

namespace Inspectron.Fastbuffer.Filesystems;

public class DirectFilesystem:IFilesystem
{
    public void Write(string path, Mat data)
    {
        // ensure path
        Directory.CreateDirectory(Path.GetDirectoryName(path));
        var bytes = data.ToBytes();
        File.WriteAllBytes(path, bytes);
    }

    public byte[] Read(string path)
    {
        return File.ReadAllBytes(path);
    }

    public void Delete(string path)
    {
        Log.Debug($"Deleting {path}");
        if (File.Exists(path))
            File.Delete(path);
    }

    public void Dispose()
    {
        
    }
}