gboolean handle_path (const char *path, struct stat * buf1, int *link_to_dir, int *stale_link) { vfs_path_t *vpath; if (DIR_IS_DOT (path) || DIR_IS_DOTDOT (path)) return FALSE; vpath = vfs_path_from_str (path); if (mc_lstat (vpath, buf1) == -1) { vfs_path_free (vpath); return FALSE; } if (S_ISDIR (buf1->st_mode)) tree_store_mark_checked (path); /* A link to a file or a directory? */ *link_to_dir = 0; *stale_link = 0; if (S_ISLNK (buf1->st_mode)) { struct stat buf2; if (mc_stat (vpath, &buf2) == 0) *link_to_dir = S_ISDIR (buf2.st_mode) != 0; else *stale_link = 1; } vfs_path_free (vpath); return TRUE; }
static int handle_dirent (dir_list * list, const char *fltr, struct dirent *dp, struct stat *buf1, int next_free, int *link_to_dir, int *stale_link) { vfs_path_t *vpath; if (dp->d_name[0] == '.' && dp->d_name[1] == 0) return 0; if (dp->d_name[0] == '.' && dp->d_name[1] == '.' && dp->d_name[2] == 0) return 0; if (!panels_options.show_dot_files && (dp->d_name[0] == '.')) return 0; if (!panels_options.show_backups && dp->d_name[NLENGTH (dp) - 1] == '~') return 0; vpath = vfs_path_from_str (dp->d_name); if (mc_lstat (vpath, buf1) == -1) { /* * lstat() fails - such entries should be identified by * buf1->st_mode being 0. * It happens on QNX Neutrino for /fs/cd0 if no CD is inserted. */ memset (buf1, 0, sizeof (*buf1)); } if (S_ISDIR (buf1->st_mode)) tree_store_mark_checked (dp->d_name); /* A link to a file or a directory? */ *link_to_dir = 0; *stale_link = 0; if (S_ISLNK (buf1->st_mode)) { struct stat buf2; if (mc_stat (vpath, &buf2) == 0) *link_to_dir = S_ISDIR (buf2.st_mode) != 0; else *stale_link = 1; } vfs_path_free (vpath); if (!(S_ISDIR (buf1->st_mode) || *link_to_dir) && (fltr != NULL) && !mc_search (fltr, dp->d_name, MC_SEARCH_T_GLOB)) return 0; /* Need to grow the *list? */ if (next_free == list->size && !grow_list (list)) return -1; return 1; }
static gboolean handle_dirent (struct dirent *dp, const char *fltr, struct stat *buf1, int *link_to_dir, int *stale_link) { vfs_path_t *vpath; if (DIR_IS_DOT (dp->d_name) || DIR_IS_DOTDOT (dp->d_name)) return FALSE; if (!panels_options.show_dot_files && (dp->d_name[0] == '.')) return FALSE; if (!panels_options.show_backups && dp->d_name[strlen (dp->d_name) - 1] == '~') return FALSE; vpath = vfs_path_from_str (dp->d_name); if (mc_lstat (vpath, buf1) == -1) { /* * lstat() fails - such entries should be identified by * buf1->st_mode being 0. * It happens on QNX Neutrino for /fs/cd0 if no CD is inserted. */ memset (buf1, 0, sizeof (*buf1)); } if (S_ISDIR (buf1->st_mode)) tree_store_mark_checked (dp->d_name); /* A link to a file or a directory? */ *link_to_dir = 0; *stale_link = 0; if (S_ISLNK (buf1->st_mode)) { struct stat buf2; if (mc_stat (vpath, &buf2) == 0) *link_to_dir = S_ISDIR (buf2.st_mode) != 0; else *stale_link = 1; } vfs_path_free (vpath); return (S_ISDIR (buf1->st_mode) || *link_to_dir != 0 || fltr == NULL || mc_search (fltr, NULL, dp->d_name, MC_SEARCH_T_GLOB)); }
int handle_path (dir_list * list, const char *path, struct stat *buf1, int next_free, int *link_to_dir, int *stale_link) { vfs_path_t *vpath; if (path[0] == '.' && path[1] == 0) return 0; if (path[0] == '.' && path[1] == '.' && path[2] == 0) return 0; vpath = vfs_path_from_str (path); if (mc_lstat (vpath, buf1) == -1) { vfs_path_free (vpath); return 0; } if (S_ISDIR (buf1->st_mode)) tree_store_mark_checked (path); /* A link to a file or a directory? */ *link_to_dir = 0; *stale_link = 0; if (S_ISLNK (buf1->st_mode)) { struct stat buf2; if (mc_stat (vpath, &buf2) == 0) *link_to_dir = S_ISDIR (buf2.st_mode) != 0; else *stale_link = 1; } vfs_path_free (vpath); /* Need to grow the *list? */ if (next_free == list->size && !grow_list (list)) return -1; return 1; }