提交 ff1c7d2d 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

fix path issue

上级 9ac421b7
......@@ -7,9 +7,7 @@ import (
constant "github.com/easysoft/zentaoatf/src/utils/const"
"github.com/easysoft/zentaoatf/src/utils/file"
langUtils "github.com/easysoft/zentaoatf/src/utils/lang"
logUtils "github.com/easysoft/zentaoatf/src/utils/log"
zentaoUtils "github.com/easysoft/zentaoatf/src/utils/zentao"
"github.com/fatih/color"
"io/ioutil"
"os"
"path"
......@@ -19,20 +17,16 @@ import (
)
func GetAllScriptsInDir(filePthParam string, files *[]string) error {
logUtils.PrintToStdOut(filePthParam, color.FgRed)
filePthParam = fileUtils.AbosutePath(filePthParam)
sep := string(os.PathSeparator)
if !fileUtils.IsDir(filePthParam) { // first call, param is file
regx := langUtils.GetSupportLangageRegx()
logUtils.PrintToStdOut(regx, color.FgRed)
pass, _ := regexp.MatchString("^*.\\."+regx+"$", filePthParam)
if pass {
pass := zentaoUtils.CheckFileIsScript(filePthParam)
logUtils.PrintToStdOut("pass", color.FgRed)
if pass {
*files = append(*files, filePthParam)
}
......
......@@ -64,7 +64,7 @@ func IsDir(f string) bool {
}
func AbosutePath(pth string) string {
if !path.IsAbs(pth) {
if !IsAbosutePath(pth) {
pth, _ = filepath.Abs(pth)
}
......@@ -75,6 +75,11 @@ func AbosutePath(pth string) string {
return pth
}
func IsAbosutePath(pth string) bool {
return path.IsAbs(pth) ||
strings.Index(pth, ":") == 1 // windows
}
func UpdateDir(pth string) string {
sepa := string(os.PathSeparator)
......@@ -93,7 +98,7 @@ func GetFilesFromParams(arguments []string) []string {
arg = AbosutePath(".")
} else if strings.Index(arg, "."+string(os.PathSeparator)) == 0 {
arg = AbosutePath(".") + arg[2:]
} else if !path.IsAbs(arg) {
} else if !IsAbosutePath(arg) {
arg = AbosutePath(".") + arg
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册