diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-07-07 02:07:39 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-07-07 02:07:39 +0200 |
commit | 8092a428d40ac682df9e80c36988043854579679 (patch) | |
tree | 789262689c0eddf1deabfc01294b36140bee65a6 /src/condition.c | |
parent | 31a5f880cf7a742e63a81bacef681939ee4e6616 (diff) |
path,unit: support globbing in conditions and path units
Diffstat (limited to 'src/condition.c')
-rw-r--r-- | src/condition.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/condition.c b/src/condition.c index a520e43436..76ee0370d2 100644 --- a/src/condition.c +++ b/src/condition.c @@ -34,6 +34,8 @@ Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) { Condition *c; + assert(type < _CONDITION_TYPE_MAX); + if (!(c = new0(Condition, 1))) return NULL; @@ -148,6 +150,9 @@ bool condition_test(Condition *c) { case CONDITION_PATH_EXISTS: return (access(c->parameter, F_OK) >= 0) == !c->negate; + case CONDITION_PATH_EXISTS_GLOB: + return (glob_exists(c->parameter) > 0) == !c->negate; + case CONDITION_PATH_IS_DIRECTORY: { struct stat st; @@ -231,6 +236,7 @@ void condition_dump_list(Condition *first, FILE *f, const char *prefix) { static const char* const condition_type_table[_CONDITION_TYPE_MAX] = { [CONDITION_PATH_EXISTS] = "ConditionPathExists", + [CONDITION_PATH_EXISTS_GLOB] = "ConditionPathExistsGlob", [CONDITION_PATH_IS_DIRECTORY] = "ConditionPathIsDirectory", [CONDITION_DIRECTORY_NOT_EMPTY] = "ConditionDirectoryNotEmpty", [CONDITION_KERNEL_COMMAND_LINE] = "ConditionKernelCommandLine", |