mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
new: api.rest is now on HTTPS (closes #5)
This commit is contained in:
parent
be570432ef
commit
47e814c9a9
4 changed files with 143 additions and 12 deletions
26
core/core.go
26
core/core.go
|
@ -2,7 +2,10 @@ package core
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -20,3 +23,26 @@ func Exec(executable string, args []string) (string, error) {
|
|||
return strings.Trim(string(raw), "\r\n\t "), nil
|
||||
}
|
||||
}
|
||||
|
||||
func Exists(path string) bool {
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func ExpandPath(path string) (string, error) {
|
||||
// Check if path is empty
|
||||
if path != "" {
|
||||
if strings.HasPrefix(path, "~") {
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// Replace only the first occurence of ~
|
||||
path = strings.Replace(path, "~", usr.HomeDir, 1)
|
||||
}
|
||||
return filepath.Abs(path)
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue