diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2017-02-13 23:00:00 +0100 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2017-02-14 18:15:12 +0000 |
commit | c01cdd4e47687bf6be505f989ff5e5b54b089ac4 (patch) | |
tree | 36116e0de13b5c329e461476d20e8ff034f74d89 /wsutil/filesystem.c | |
parent | fe78e1302f6076291e7270de2e8443ddb2c082af (diff) | |
download | wireshark-c01cdd4e47687bf6be505f989ff5e5b54b089ac4.tar.gz |
Qt: Reset Default profile support
Add support for resetting the Default profile by deleting it in
the Profile Dialog. All profile files will be deleted and all
other files will be kept.
Change-Id: I795a6db3ee7b2c29e7aba461183e6cc411798b75
Reviewed-on: https://code.wireshark.org/review/20097
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Diffstat (limited to 'wsutil/filesystem.c')
-rw-r--r-- | wsutil/filesystem.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index 4fffcd4016..7ea4776a91 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -1471,9 +1471,43 @@ delete_directory (const char *directory, char **pf_dir_path_return) return ret; } +static int +reset_default_profile(char **pf_dir_path_return) +{ + const char *profile_dir = get_persconffile_dir(NULL); + gchar *filename, *del_file; + GList *files, *file; + int ret = 0; + + files = g_hash_table_get_keys(profile_files); + file = g_list_first(files); + while (file) { + filename = (gchar *)file->data; + del_file = g_strdup_printf("%s%s%s", profile_dir, G_DIR_SEPARATOR_S, filename); + + if (file_exists(del_file)) { + ret = ws_remove(del_file); + if (ret != 0) { + *pf_dir_path_return = g_strdup(profile_dir); + g_free(del_file); + return ret; + } + } + + g_free(del_file); + file = g_list_next(file); + } + + return 0; +} + int delete_persconffile_profile(const char *profilename, char **pf_dir_path_return) { + if (strcmp(profilename, DEFAULT_PROFILE) == 0) { + return reset_default_profile(pf_dir_path_return); + } + const char *profile_dir = get_persconffile_dir(profilename); int ret = 0; |