aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2002-01-04 21:50:26 +0000
committerGuy Harris <guy@alum.mit.edu>2002-01-04 21:50:26 +0000
commite0593df4a7384d228f781589c4bcd43a9ea2fc4e (patch)
tree148a24da016a271d5ce8af240bba2da1348d2095 /epan
parentcb489a92bb07d38ab037d72515e20c15374c9b69 (diff)
If the "parent directory" of what would be the personal configuration
file directory is just a drive letter (e.g., if the directory is "c:\Ethereal"), don't "stat()" it to see if it exists (as that'll fail, falsely leading us to believe it needs to be created; the attempt to do so will fail), just assume it exists. svn path=/trunk/; revision=4482
Diffstat (limited to 'epan')
-rw-r--r--epan/filesystem.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/epan/filesystem.c b/epan/filesystem.c
index 7d04e40e3c..ccbe167542 100644
--- a/epan/filesystem.c
+++ b/epan/filesystem.c
@@ -1,7 +1,7 @@
/* filesystem.c
* Filesystem utility routines
*
- * $Id: filesystem.c,v 1.15 2001/10/24 09:22:23 guy Exp $
+ * $Id: filesystem.c,v 1.16 2002/01/04 21:50:26 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -405,6 +405,7 @@ create_persconffile_dir(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
struct stat s_buf;
int ret;
@@ -416,12 +417,21 @@ create_persconffile_dir(char **pf_dir_path_return)
* Does the parent directory of that directory
* exist? %APPDATA% may not exist even though
* %USERPROFILE% does.
+ *
+ * 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.
*/
pf_dir_path_copy = g_strdup(pf_dir_path);
pf_dir_parent_path = get_dirname(pf_dir_path_copy);
- if (stat(pf_dir_parent_path, &s_buf) != 0) {
+ pf_dir_parent_path_len = strlen(pf_dir_parent_path);
+ if (pf_dir_parent_path_len > 0
+ && pf_dir_parent_path[pf_dir_parent_path_len - 1] != ':'
+ && stat(pf_dir_parent_path, &s_buf) != 0) {
/*
- * No - make it first.
+ * No, it doesn't exist - make it first.
*/
ret = mkdir(pf_dir_parent_path);
if (ret == -1) {