package storage

import "path/filepath"

const (
	storageRootName = "storage"
	configFileName  = "config.json"

	ID      = "zhaocy.df"
	Version = "zhaocy/df/v1"
)

type Storage interface {
	Root() string
	ConfigStorage
}

type ConfigStorage interface {
	LoadConfig() (*Config, error)
	StoreConfig(s *Config) error
}

func storageRootPath(s Storage) string {
	return filepath.Join(s.Root(), storageRootName)
}

func configPath(s Storage) string {
	return filepath.Join(storageRootPath(s), configFileName)
}
