Condition* condition_new(ConditionType type, const char *parameter, bool trigger, bool negate) {
Condition *c;
- c = new0(Condition, 1);
+ if (!(c = new0(Condition, 1)))
+ return NULL;
+
c->type = type;
c->trigger = trigger;
c->negate = negate;
case CONDITION_PATH_EXISTS:
return (access(c->parameter, F_OK) >= 0) == !c->negate;
+ case CONDITION_PATH_IS_DIRECTORY: {
+ struct stat st;
+
+ if (lstat(c->parameter, &st) < 0)
+ return !c->negate;
+ return S_ISDIR(st.st_mode) == !c->negate;
+ }
+
case CONDITION_DIRECTORY_NOT_EMPTY: {
int k;