dir_entry* path_info(const char* path) { debugf(DBG_LEVEL_EXT, "path_info(%s)", path); char dir[MAX_PATH_SIZE]; dir_for(path, dir); dir_entry* tmp; if (!caching_list_directory(dir, &tmp)) { debugf(DBG_LEVEL_EXT, "exit 0: path_info(%s) "KYEL"[CACHE-DIR-MISS]", dir); return NULL; } else debugf(DBG_LEVEL_EXT, "path_info(%s) "KGRN"[CACHE-DIR-HIT]", dir); //iterate in file list obtained from cache or downloaded for (; tmp; tmp = tmp->next) { if (!strcmp(tmp->full_name, path)) { debugf(DBG_LEVEL_EXT, "exit 1: path_info(%s) "KGRN"[CACHE-FILE-HIT]", path); return tmp; } } //miss in case the file is not found on a cached folder debugf(DBG_LEVEL_EXT, "exit 2: path_info(%s) "KYEL"[CACHE-MISS]", path); return NULL; }
static int cfs_readdir(const char *path, void *buf, fuse_fill_dir_t filldir, off_t offset, struct fuse_file_info *info) { dir_entry *de; if (!caching_list_directory(path, &de)) return -ENOLINK; filldir(buf, ".", NULL, 0); filldir(buf, "..", NULL, 0); for (; de; de = de->next) filldir(buf, de->name, NULL, 0); return 0; }
static dir_entry *path_info(const char *path) { char dir[MAX_PATH_SIZE]; dir_for(path, dir); dir_entry *tmp; if (!caching_list_directory(dir, &tmp)) return NULL; for (; tmp; tmp = tmp->next) { if (!strcmp(tmp->full_name, path)) return tmp; } return NULL; }
static int cfs_readdir(const char* path, void* buf, fuse_fill_dir_t filldir, off_t offset, struct fuse_file_info* info) { debugf(DBG_LEVEL_NORM, KBLU "cfs_readdir(%s)", path); dir_entry* de; if (!caching_list_directory(path, &de)) { debug_list_cache_content(); debugf(DBG_LEVEL_NORM, KRED "exit 0: cfs_readdir(%s)", path); return -ENOLINK; } filldir(buf, ".", NULL, 0); filldir(buf, "..", NULL, 0); for (; de; de = de->next) filldir(buf, de->name, NULL, 0); debug_list_cache_content(); debugf(DBG_LEVEL_NORM, KBLU "exit 1: cfs_readdir(%s)", path); return 0; }