mirror of
https://github.com/cloudreve/cloudreve.git
synced 2025-11-02 11:42:22 +08:00
Fix: get execute file path dynamically
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -45,3 +47,12 @@ func SplitPath(path string) []string {
|
||||
func FormSlash(old string) string {
|
||||
return path.Clean(strings.ReplaceAll(old, "\\", "/"))
|
||||
}
|
||||
|
||||
// RelativePath 获取相对可执行文件的路径
|
||||
func RelativePath(name string) string {
|
||||
if filepath.IsAbs(name) {
|
||||
return name
|
||||
}
|
||||
e, _ := os.Executable()
|
||||
return filepath.Join(filepath.Dir(e), name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user