summaryrefslogtreecommitdiff
path: root/wsutil
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-10-28 16:06:18 -0700
committerGuy Harris <guy@alum.mit.edu>2015-10-28 23:07:07 +0000
commit6ada7d53899d49f0c173ad241f8e6f5dfee590d9 (patch)
treebc9335fb913bdd3932e0605fbb343532800a47f0 /wsutil
parent0f8e32c515057bf605458c2cd3ce74fda2ed81e8 (diff)
downloadwireshark-6ada7d53899d49f0c173ad241f8e6f5dfee590d9.tar.gz
Just use g_mkdir_with_parents() to make the .config directory on UN*X.
It will create all the relevant directories (if it can), using g_mkdir(), which is a wrapper for mkdir() on UN*X - just as ws_mkdir() is, so we don't need to make our own copy that uses ws_mkdir. Bug: 11645 Change-Id: I68affc6fabccf58dace75af078d9bfd67a1b47b2 Reviewed-on: https://code.wireshark.org/review/11373 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/filesystem.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index 83c9a26c5f..efa5f34041 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -1525,8 +1525,10 @@ int
create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
{
const char *pf_dir_path;
+#ifdef _WIN32
char *pf_dir_path_copy, *pf_dir_parent_path;
size_t pf_dir_parent_path_len;
+#endif
ws_statb64 s_buf;
int ret;
@@ -1554,25 +1556,23 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
pf_dir_path = get_persconffile_dir(profilename);
if (ws_stat64(pf_dir_path, &s_buf) != 0 && errno == ENOENT) {
+#ifdef _WIN32
/*
* Does the parent directory of that directory
* exist? %APPDATA% may not exist even though
- * %USERPROFILE% does, and ~/.config might not exist
- * even though ~ exists.
+ * %USERPROFILE% does.
*
* We check for the existence of the directory
- * by doing a ws_stat64() on it (unless this
- * is on Windows and it's just a drive letter)
- * If it's a drive letter on Windows, or if the
- * ws_stat64 succeeds, we assume it exists.
+ * by first checking whether the parent directory
+ * is just a drive letter and, if it's not, by
+ * doing a "stat()" on it. If it's a drive letter,
+ * or if the "stat()" succeeds, we assume it exists.
*/
pf_dir_path_copy = g_strdup(pf_dir_path);
pf_dir_parent_path = get_dirname(pf_dir_path_copy);
pf_dir_parent_path_len = strlen(pf_dir_parent_path);
if (pf_dir_parent_path_len > 0
-#ifdef _WIN32
&& pf_dir_parent_path[pf_dir_parent_path_len - 1] != ':'
-#endif
&& ws_stat64(pf_dir_parent_path, &s_buf) != 0) {
/*
* No, it doesn't exist - make it first.
@@ -1585,6 +1585,9 @@ create_persconffile_profile(const char *profilename, char **pf_dir_path_return)
}
g_free(pf_dir_path_copy);
ret = ws_mkdir(pf_dir_path, 0755);
+#else
+ ret = g_mkdir_with_parents(pf_dir_path, 0755);
+#endif
} else {
/*
* Something with that pathname exists; if it's not