浏览代码

custom workDir function to handle speical case in Windows

tags/v0.9.99
Unknwon 8 年前
父节点
当前提交
1490e862cc
共有 1 个文件被更改,包括 12 次插入1 次删除
  1. 12
    1
      modules/setting/setting.go

+ 12
- 1
modules/setting/setting.go 查看文件

@@ -168,7 +168,18 @@ func ExecPath() (string, error) {
// WorkDir returns absolute path of work directory.
func WorkDir() (string, error) {
execPath, err := ExecPath()
return path.Dir(strings.Replace(execPath, "\\", "/", -1)), err
if err != nil {
return execPath, err
}

// Note: we don't use path.Dir here because it does not handle case
// which path starts with two "/" in Windows: "//psf/Home/..."
execPath = strings.Replace(execPath, "\\", "/", -1)
i := strings.LastIndex(execPath, "/")
if i == -1 {
return execPath, nil
}
return execPath[:i], nil
}

func forcePathSeparator(path string) {

正在加载...
取消
保存