Rename packages

This commit is contained in:
Tom Wiesing 2022-09-14 14:17:08 +02:00
parent 49b8760527
commit ef1243ea39
No known key found for this signature in database
47 changed files with 524 additions and 369 deletions

View file

@ -0,0 +1,33 @@
package config
import (
"os"
"path/filepath"
"github.com/FAU-CDI/wisski-distillery/internal/core"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
)
// ExecutablePath returns the path to the executable of this distillery.
func (cfg Config) ExecutablePath() string {
return filepath.Join(cfg.DeployRoot, core.Executable)
}
// UsingDistilleryExecutable checks if the current process is using the distillery executable
func (cfg Config) UsingDistilleryExecutable() bool {
exe, err := os.Executable()
if err != nil {
return false
}
return fsx.SameFile(exe, cfg.ExecutablePath())
}
// CurrentExecutable returns the path to the current executable being used.
// When it does not exist, falls back to the default executable.
func (cfg Config) CurrentExecutable() string {
exe, err := os.Executable()
if err != nil || !fsx.IsFile(exe) {
return cfg.ExecutablePath()
}
return exe
}