summaryrefslogtreecommitdiff
path: root/wsutil/filesystem.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-10-28 12:44:53 -0700
committerGuy Harris <guy@alum.mit.edu>2015-10-28 19:46:05 +0000
commit0f8e32c515057bf605458c2cd3ce74fda2ed81e8 (patch)
tree7604c3d3916625cf5bff39c3a9c91dfe26e51082 /wsutil/filesystem.c
parent4c69f10aa42070616b92886f104f5a16eb88f00c (diff)
downloadwireshark-0f8e32c515057bf605458c2cd3ce74fda2ed81e8.tar.gz
Do the "create parent of config file directory" stuff on UN*X as well.
~ obviously exists, but ~/.config might not, making it impossible to create ~/.config/wireshark. Bug: 11645 Change-Id: Ia267b168eb7b1438d4c35a6bb89df9d7bfcbd3f3 Reviewed-on: https://code.wireshark.org/review/11368 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil/filesystem.c')
-rw-r--r--wsutil/filesystem.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c
index a24ce33a2c..83c9a26c5f 100644
--- a/wsutil/filesystem.c
+++ b/wsutil/filesystem.c
@@ -1525,10 +1525,8 @@ 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;
@@ -1556,23 +1554,25 @@ 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.
+ * %USERPROFILE% does, and ~/.config might not exist
+ * even though ~ exists.
*
* We check for the existence of the directory
- * 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.
+ * 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.
*/
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,9 +1585,6 @@ 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 = ws_mkdir(pf_dir_path, 0755);
-#endif
} else {
/*
* Something with that pathname exists; if it's not