30 lines
506 B
Go
30 lines
506 B
Go
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)
|
|
}
|