diff options
author | Anders Broman <anders.broman@ericsson.com> | 2010-08-10 11:36:18 +0000 |
---|---|---|
committer | Anders Broman <anders.broman@ericsson.com> | 2010-08-10 11:36:18 +0000 |
commit | 26274eb7018d3bff583687f2a8da4f02cf31620d (patch) | |
tree | 70c4c6165826ea6f20389892809c1b0761b0b805 | |
parent | 777a4ee10ee61ed1e33b56921c364dd91a753359 (diff) |
From Cal Turney:
Remember folder of capture selected from Welcome screen file dialog.
https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5038
svn path=/trunk/; revision=33758
-rw-r--r-- | epan/filesystem.c | 2 | ||||
-rw-r--r-- | epan/filesystem.h | 7 | ||||
-rw-r--r-- | epan/libwireshark.def | 1 | ||||
-rw-r--r-- | gtk/main.c | 12 |
4 files changed, 21 insertions, 1 deletions
diff --git a/epan/filesystem.c b/epan/filesystem.c index 77306bd728..2d15a9ca83 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -93,7 +93,7 @@ static GHashTable *profile_files = NULL; * character in the pathname, or NULL if the pathname contains no * separators. */ -static char * +char * find_last_pathname_separator(const char *path) { char *separator; diff --git a/epan/filesystem.h b/epan/filesystem.h index 6e459393f3..ce5cc386bc 100644 --- a/epan/filesystem.h +++ b/epan/filesystem.h @@ -218,6 +218,13 @@ extern const char *file_write_error_message(int err); */ extern const char *get_basename(const char *); + /* + * Given a pathname, return a pointer to the last pathname separator + * character in the pathname, or NULL if the pathname contains no + * separators. + */ +extern char *find_last_pathname_separator(const char *path); + /* * Given a pathname, return a string containing everything but the * last component. NOTE: this overwrites the pathname handed into diff --git a/epan/libwireshark.def b/epan/libwireshark.def index 8e7397b6b2..d3ab3b0a01 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -425,6 +425,7 @@ find_conversation find_or_create_conversation find_dissector find_dissector_table +find_last_pathname_separator find_protocol_by_id find_stream_circ find_tap_id diff --git a/gtk/main.c b/gtk/main.c index 9b58327062..e792241398 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -1506,9 +1506,21 @@ main_cf_cb_file_read_started(capture_file *cf _U_) static void main_cf_cb_file_read_finished(capture_file *cf) { + gchar* cf_path_end; + gchar* dir_path; + size_t dir_path_len; + if (!cf->is_tempfile && cf->filename) { /* Add this filename to the list of recent files in the "Recent Files" submenu */ add_menu_recent_capture_file(cf->filename); + + /* Remember folder for next Open dialog and saved in recent */ + cf_path_end = find_last_pathname_separator(cf->filename); + dir_path_len = (cf_path_end - cf->filename); + dir_path = g_malloc (dir_path_len + 1); + strncpy(dir_path, cf->filename, dir_path_len); + dir_path[dir_path_len++] = '\0'; + set_last_open_dir(dir_path); } set_display_filename(cf); |