func (s *OS) CacheDir() string {
	return s.cacheDir
}
CacheDir represents the Cache directory (e.g. /var/cache/therm/).
package sys
import (
	"net"
	"os"
	"os/user"
	"path/filepath"
	"github.com/pkg/errors"
	"github.com/spoke-d/thermionic/internal/fsys"
)
type OS struct {
	varDir   string
	cacheDir string
	logDir   string
}
func DefaultOS() *OS {
	return &OS{
		varDir:   VarPath(),
		cacheDir: CachePath(),
		logDir:   LogPath(),
	}
}
func New(varDir, cacheDir, logDir string) *OS {
	return &OS{
		varDir:   varDir,
		cacheDir: cacheDir,
		logDir:   logDir,
	}
}
func (s *OS) Init(fileSystem fsys.FileSystem) error {
	err := s.initDirs(fileSystem)
	return errors.WithStack(err)
}
func (s *OS) initDirs(fileSystem fsys.FileSystem) error {
	dirs := []struct {
		path string
		mode os.FileMode
	}{
		{s.varDir, 0711},
		{s.cacheDir, 0700},
		{s.logDir, 0700},
		{filepath.Join(s.varDir, "database"), 0700},
	}
	for _, dir := range dirs {
		err := fileSystem.Mkdir(dir.path, dir.mode)
		if err != nil && !os.IsExist(errors.Cause(err)) {
			return errors.Wrapf(err, "failed to init dir %s", dir.path)
		}
	}
	return nil
}
func (s *OS) LocalDatabasePath() string {
	return filepath.Join(s.varDir, "database", "local.db")
}
func (s *OS) GlobalDatabaseDir() string {
	return filepath.Join(s.varDir, "database", "global")
}
func (s *OS) GlobalDatabasePath() string {
	return filepath.Join(s.GlobalDatabaseDir(), "db.bin")
}
func (s *OS) LocalNoncePath() string {
	return filepath.Join(s.varDir, "nonce.txt")
}
func (s *OS) VarDir() string {
	return s.varDir
}