Files
Reims-Go/internal/cli/network_start.go

28 lines
515 B
Go

package cli
import (
"os"
"path/filepath"
"github.com/Nwflower/reims-go/internal/config"
)
func canHandoffDataRoot(root string) bool {
cfg, err := config.Load("")
return err == nil && sameDataRoot(root, cfg.DataRoot)
}
func sameDataRoot(a, b string) bool {
a, aerr := filepath.Abs(a)
b, berr := filepath.Abs(b)
if aerr != nil || berr != nil {
return false
}
if a == b {
return true
}
ast, aerr := os.Stat(a)
bst, berr := os.Stat(b)
return aerr == nil && berr == nil && os.SameFile(ast, bst)
}