db/update/InotifyQueue: use StringAfterPrefix()

This commit is contained in:
Max Kellermann 2015-11-06 09:49:39 +01:00
parent 3dc989bccb
commit e7ef7f5159

View File

@ -24,8 +24,6 @@
#include "Log.hxx"
#include "util/StringCompare.hxx"
#include <string.h>
/**
* Wait this long after the last change before calling
* update_enqueue(). This increases the probability that updates can
@ -55,14 +53,16 @@ InotifyQueue::OnTimeout()
}
}
gcc_pure
static bool
path_in(const char *path, const char *possible_parent)
{
size_t length = strlen(possible_parent);
if (StringIsEmpty(path))
return true;
return StringIsEmpty(path) ||
(memcmp(possible_parent, path, length) == 0 &&
(path[length] == 0 || path[length] == '/'));
auto rest = StringAfterPrefix(path, possible_parent);
return rest != nullptr &&
(StringIsEmpty(rest) || rest[0] == '/');
}
void