github.com/safing/portbase@v0.19.5/dataroot/root.go (about)

     1  package dataroot
     2  
     3  import (
     4  	"errors"
     5  	"os"
     6  
     7  	"github.com/safing/portbase/utils"
     8  )
     9  
    10  var root *utils.DirStructure
    11  
    12  // Initialize initializes the data root directory.
    13  func Initialize(rootDir string, perm os.FileMode) error {
    14  	if root != nil {
    15  		return errors.New("already initialized")
    16  	}
    17  
    18  	root = utils.NewDirStructure(rootDir, perm)
    19  	return root.Ensure()
    20  }
    21  
    22  // Root returns the data root directory.
    23  func Root() *utils.DirStructure {
    24  	return root
    25  }