desc init_env(const char *dir, char *file_path, char *link_path) { desc in_desc = {-1, -1, -1, -1}; if (mkdir(dir, 0777) < 0) { err("error in creating directory: %s, %s", dir, strerror(errno)); return in_desc; } in_desc.inot = inotify_init(); if (in_desc.inot < 0) { err("inotify_init () Failed, %s", strerror(errno)); rmdir(dir); return in_desc; } if (snprintf(file_path, BUF_SIZE, "%s/%s", dir, filename) >= BUF_SIZE) { err("filename %s is too long", filename); rmdir(dir); return in_desc; } if (snprintf(link_path, BUF_SIZE, "%s/%s", dir, linkname) >= BUF_SIZE) { err("filename %s is too long", linkname); rmdir(dir); return in_desc; } in_desc.dir = addWatcher(in_desc.inot, dir); if (createFiles(file_path, filename, link_path)) { return in_desc; } in_desc.link = addWatcher(in_desc.inot, link_path); in_desc.file = addWatcher(in_desc.inot, file_path); return in_desc; }
MtIndicatorItem::MtIndicatorItem(MtTemplateItem *parent, MtDataItem *watch):MtDataItem(parent) { addWatcher(watch); }