diff options
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/filesystem.c | 66 | ||||
-rw-r--r-- | wsutil/filesystem.h | 5 |
2 files changed, 46 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); diff --git a/wsutil/filesystem.h b/wsutil/filesystem.h index 0edd0b2adc..f09e5ccaea 100644 --- a/wsutil/filesystem.h +++ b/wsutil/filesystem.h @@ -125,6 +125,11 @@ WS_DLL_PUBLIC gboolean has_global_profiles(void); WS_DLL_PUBLIC char *get_profiles_dir(void); /* + * Create the directory used to store configuration profile directories. + */ +WS_DLL_PUBLIC int create_profiles_dir(char **pf_dir_path_return); + +/* * Get the directory used to store global configuration profile directories. * Caller must free the returned string */ |