go-ethereum/ethutil/path.go

21 lines
293 B
Go
Raw Normal View History

2014-07-01 13:08:18 -05:00
package ethutil
import (
"os/user"
"strings"
)
func ExpandHomePath(p string) (path string) {
path = p
// Check in case of paths like "/something/~/something/"
if path[:2] == "~/" {
usr, _ := user.Current()
dir := usr.HomeDir
path = strings.Replace(p, "~", dir, 1)
}
return
}