using System.IO;
using CounterDrone.Core;
using UnityEngine;

namespace CounterDrone.Unity
{
    public class UnityPathProvider : IPathProvider
    {
        private string _root;

        public string GetDataRoot()
        {
            if (_root == null)
            {
                _root = Application.persistentDataPath;
                Directory.CreateDirectory(_root);
            }
            return _root;
        }

        public string GetMainDbPath() => Path.Combine(GetDataRoot(), "main.db");

        public string GetFramesDir()
        {
            var dir = Path.Combine(GetDataRoot(), "frames");
            Directory.CreateDirectory(dir);
            return dir;
        }

        public string GetModelsDir()
        {
            var dir = Path.Combine(GetDataRoot(), "models");
            Directory.CreateDirectory(dir);
            return dir;
        }
    }
}
