/* Returns non-zero if selection doesn't mix files and directories, otherwise * zero is returned. */ static int selection_is_consistent(const FileView *const view) { if(view->selected_files > 1) { int files = 0, dirs = 0; int i; for(i = 0; i < view->list_rows; i++) { char full[PATH_MAX]; const dir_entry_t *const curr = &view->dir_entry[i]; if(!curr->selected) { continue; } get_full_path_of(curr, sizeof(full), full); if(is_dir_entry(full, curr->type)) { dirs++; } else { files++; } } if(dirs > 0 && files > 0) { return 0; } } return 1; }
/* Returns non-zero if selection doesn't mix files and directories, otherwise * zero is returned. */ static int selection_is_consistent(FileView *view) { int files = 0, dirs = 0; dir_entry_t *entry; if(view->selected_files < 2) { return 1; } entry = NULL; while(iter_selected_entries(view, &entry)) { char full[PATH_MAX]; get_full_path_of(entry, sizeof(full), full); if(is_dir_entry(full, entry->type)) { ++dirs; } else { ++files; } } return (dirs == 0 || files == 0); }
static void handle_file(FileView *view, FileHandleExec exec, FileHandleLink follow) { char full_path[PATH_MAX]; int executable; int runnable; const dir_entry_t *const curr = &view->dir_entry[view->list_pos]; get_full_path_of(curr, sizeof(full_path), full_path); if(is_dir(full_path) || is_unc_root(view->curr_dir)) { if(!curr->selected && (curr->type != FT_LINK || follow == FHL_NO_FOLLOW)) { open_dir(view); return; } } runnable = is_runnable(view, full_path, curr->type, follow == FHL_FOLLOW); executable = is_executable(full_path, curr, exec == FHE_NO_RUN, runnable); if(stats_file_choose_action_set() && (executable || runnable)) { /* The call below does not return. */ vifm_choose_files(view, 0, NULL); } if(executable && !is_dir_entry(full_path, curr->type)) { execute_file(full_path, exec == FHE_ELEVATE_AND_RUN); } else if(runnable) { run_selection(view, exec == FHE_NO_RUN); } else if(curr->type == FT_LINK) { follow_link(view, follow == FHL_FOLLOW); } }