X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=do.go;h=8c2b62c91ffd09ecf7673a612afb937a299440bd;hb=d63dbd051c650ea69c42bc08dd6bba8baf661d65;hp=1846414f7e979f14a7f1b725bca9da31e4b156c0;hpb=edb601644735972fac3efcdc27849b5b9b1f5fb7;p=goredo.git diff --git a/do.go b/do.go index 1846414..8c2b62c 100644 --- a/do.go +++ b/do.go @@ -1,6 +1,6 @@ /* -goredo -- redo implementation on pure Go -Copyright (C) 2020-2021 Sergey Matveev +goredo -- djb's redo implementation on pure Go +Copyright (C) 2020-2023 Sergey Matveev This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ const ( var TopDir string func existsDo(fdDep *os.File, cwd, pth string) (bool, error) { - if _, err := os.Stat(path.Join(cwd, pth)); err == nil { + if FileExists(path.Join(cwd, pth)) { return true, nil } return false, ifcreate(fdDep, pth) @@ -60,7 +60,7 @@ func findDo(fdDep *os.File, cwd, tgt string) (string, int, error) { doFile = strings.Join(append( []string{"default"}, append(exts, "do")..., ), ".") - if len(levels) > 0 || doFile != doFileOrig { + if len(levels) > 0 || (doFile != doFileOrig && doFile != tgt) { exists, err = existsDo(fdDep, cwd, path.Join(updir, doFile)) if err != nil { return "", 0, err @@ -72,7 +72,7 @@ func findDo(fdDep *os.File, cwd, tgt string) (string, int, error) { exts = exts[1:] } doFile = "default.do" - if len(levels) > 0 || doFile != doFileOrig { + if len(levels) > 0 || (doFile != doFileOrig && doFile != tgt) { exists, err = existsDo(fdDep, cwd, path.Join(updir, doFile)) if err != nil { return "", 0, err @@ -82,14 +82,14 @@ func findDo(fdDep *os.File, cwd, tgt string) (string, int, error) { } } levels = append(levels, "..") - dirAbs, err := filepath.Abs(updir) + dirAbs, err := filepath.Abs(path.Join(cwd, updir)) if err != nil { panic(err) } if dirAbs == TopDir { break } - if _, err = os.Stat(path.Join(dirAbs, RedoDir, TopFile)); err == nil { + if FileExists(path.Join(dirAbs, RedoDir, TopFile)) { break } if dirAbs == dirAbsPrev {