Improve core module to take care of dir structures and db init
This commit is contained in:
27
core/structure/dirs.go
Normal file
27
core/structure/dirs.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package structure
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/safing/portbase/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
root *utils.DirStructure
|
||||
)
|
||||
|
||||
// Initialize initializes the data root directory
|
||||
func Initialize(rootDir string, perm os.FileMode) error {
|
||||
root = utils.NewDirStructure(rootDir, perm)
|
||||
return root.Ensure()
|
||||
}
|
||||
|
||||
// Root returns the data root directory.
|
||||
func Root() *utils.DirStructure {
|
||||
return root
|
||||
}
|
||||
|
||||
// NewRootDir calls ChildDir() on the data root directory.
|
||||
func NewRootDir(dirName string, perm os.FileMode) (childDir *utils.DirStructure) {
|
||||
return root.ChildDir(dirName, perm)
|
||||
}
|
||||
Reference in New Issue
Block a user