Add missing watch event for files

If a file was supposed to exist in a directory, and it didn't exist yet,
when it gets created, we should notice, and cause an event so that we
wake up and actually see about then creating that file!
This commit is contained in:
James Shubin
2015-09-26 03:28:05 -04:00
parent 8dbca80853
commit 451fb35f93
3 changed files with 50 additions and 1 deletions

11
misc.go
View File

@@ -52,6 +52,17 @@ func HasPathPrefix(p, prefix string) bool {
return true
}
// Delta of path prefix, tells you how many path tokens different the prefix is
func PathPrefixDelta(p, prefix string) int {
if !HasPathPrefix(p, prefix) {
return -1
}
patharray := PathSplit(p)
prefixarray := PathSplit(prefix)
return len(patharray) - len(prefixarray)
}
func PathIsDir(p string) bool {
return p[len(p)-1:] == "/" // a dir has a trailing slash in this context
}