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)
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 {
FdOODTgts *os.File
FdOODTgtsLock *os.File
+ FileExistsCache map[string]bool = make(map[string]bool)
+
ErrMissingTarget = errors.New("invalid format of .rec: missing Target")
)
+func FileExists(p string) bool {
+ if exists, known := FileExistsCache[p]; known {
+ return exists
+ }
+ _, err := os.Stat(p)
+ if err == nil {
+ FileExistsCache[p] = true
+ return true
+ }
+ if os.IsNotExist(err) {
+ FileExistsCache[p] = false
+ }
+ return false
+}
+
type TgtError struct {
Tgt string
Err error
func isSrc(cwd, tgt string) bool {
d, f := path.Split(path.Join(cwd, tgt))
- if _, err := os.Stat(path.Join(d, f)); err != nil {
+ if !FileExists(path.Join(d, f)) {
return false
}
- if _, err := os.Stat(path.Join(d, f+".do")); err == nil {
+ if FileExists(path.Join(d, f+".do")) {
return false
}
- if _, err := os.Stat(path.Join(d, RedoDir, f+DepSuffix)); err == nil {
+ if FileExists(path.Join(d, RedoDir, f+DepSuffix)) {
return false
}
return true
tracef(CDebug, "ood: %s%s -> already built", indent, tgtOrig)
return false, nil
}
- if _, err := os.Stat(path.Join(cwd, tgt)); err != nil && os.IsNotExist(err) {
+ if !FileExists(path.Join(cwd, tgt)) {
tracef(CDebug, "ood: %s%s -> non-existent", indent, tgtOrig)
return true, nil
}
ood := false
for _, dep := range depInfo.ifcreates {
- if _, err := os.Stat(path.Join(cwd, dep)); err == nil {
+ if FileExists(path.Join(cwd, dep)) {
tracef(CDebug, "ood: %s%s -> %s created", indent, tgtOrig, dep)
ood = true
goto Done