int goto_selected_file(menu_data_t *m, FileView *view, const char spec[], int try_open) { char *path_buf; int line_num; path_buf = parse_file_spec(spec, &line_num, get_relative_path_base(m, view)); if(path_buf == NULL) { show_error_msg("Memory Error", "Unable to allocate enough memory"); return 1; } if(!path_exists(path_buf, NODEREF)) { show_error_msgf("Missing file", "File \"%s\" doesn't exist", path_buf); free(path_buf); return 1; } if(try_open) { open_selected_file(path_buf, line_num); } else { navigate_to_selected_file(view, path_buf); } free(path_buf); return 0; }
void goto_selected_file(FileView *view, const char spec[], int try_open) { char *path_buf; int line_num; path_buf = parse_spec(spec, &line_num); if(path_buf == NULL) { show_error_msg("Memory Error", "Unable to allocate enough memory"); return; } if(access(path_buf, F_OK) == 0) { if(try_open) { open_selected_file(path_buf, line_num); } else { navigate_to_selected_file(view, path_buf); } } else { show_error_msgf("Missing file", "File \"%s\" doesn't exist", path_buf); } free(path_buf); }