diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2017-06-20 15:12:48 -0400 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-06-20 19:45:03 +0000 |
commit | 4f1053c5464de12b635a8cf4128b78d51f6f3deb (patch) | |
tree | ad6f1008934c656ab10c57ed9bb1884453ca59f0 /wsutil/filesystem.c | |
parent | c919c625025afdca318a1a3413b268d00ad1985c (diff) |
Qt: Create the user profiles dir at startup
Ensure the user profiles directory is created at startup so that
users can put downloaded profiles without creating the directory.
Change-Id: Ib06bb3055daef8fd9e78d7887ce56f8fe50e48bf
Reviewed-on: https://code.wireshark.org/review/22275
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wsutil/filesystem.c')
-rw-r--r-- | wsutil/filesystem.c | 66 |
1 files changed, 41 insertions, 25 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index e4f3c3bed8..8738db204e 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -1378,6 +1378,45 @@ get_profiles_dir(void) G_DIR_SEPARATOR_S, PROFILES_DIR); } +int +create_profiles_dir(char **pf_dir_path_return) +{ + char *pf_dir_path; + ws_statb64 s_buf; + + /* + * Create the "Default" personal configuration files directory, if necessary. + */ + if (create_persconffile_profile (NULL, pf_dir_path_return) == -1) { + return -1; + } + + /* + * Check if profiles directory exists. + * If not then create it. + */ + pf_dir_path = get_profiles_dir (); + if (ws_stat64(pf_dir_path, &s_buf) != 0) { + if (errno != ENOENT) { + /* Some other problem; give up now. */ + *pf_dir_path_return = pf_dir_path; + return -1; + } + + /* + * It doesn't exist; try to create it. + */ + int ret = ws_mkdir(pf_dir_path, 0755); + if (ret == -1) { + *pf_dir_path_return = pf_dir_path; + return ret; + } + } + g_free(pf_dir_path); + + return 0; +} + char * get_global_profiles_dir(void) { @@ -1556,34 +1595,11 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return) if (profilename) { /* - * Create the "Default" personal configuration files directory, if necessary. + * Create the personal profiles directory, if necessary. */ - if (create_persconffile_profile (NULL, pf_dir_path_return) == -1) { + if (create_profiles_dir(pf_dir_path_return) == -1) { return -1; } - - /* - * Check if profiles directory exists. - * If not then create it. - */ - pf_dir_path = get_profiles_dir (); - if (ws_stat64(pf_dir_path, &s_buf) != 0) { - if (errno != ENOENT) { - /* Some other problem; give up now. */ - *pf_dir_path_return = pf_dir_path; - return -1; - } - - /* - * It doesn't exist; try to create it. - */ - ret = ws_mkdir(pf_dir_path, 0755); - if (ret == -1) { - *pf_dir_path_return = pf_dir_path; - return ret; - } - } - g_free(pf_dir_path); } pf_dir_path = get_persconffile_dir(profilename); |