mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-07 17:40:57 +08:00
添加了使用函数CurrentDir
This commit is contained in:
10
util/util.go
10
util/util.go
@@ -4,6 +4,8 @@ import (
|
||||
"bufio"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// 检查文件或目录是否存在
|
||||
@@ -38,3 +40,11 @@ func ReadFileLines(filename string) (lines []string, err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func CurrentDir(path ...string) string {
|
||||
_, currentFilePath, _, _ := runtime.Caller(1)
|
||||
if len(path) == 0 {
|
||||
return filepath.Dir(currentFilePath)
|
||||
}
|
||||
return filepath.Join(filepath.Dir(currentFilePath), filepath.Join(path...))
|
||||
}
|
||||
|
Reference in New Issue
Block a user