diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-10-23 08:15:11 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-10-23 08:15:11 +0000 |
commit | c68d6a715843a13a6e774fa3c5856a1099b596fa (patch) | |
tree | b28ae5ffda3cf8f18b7b0a38e81256f0d6519f61 /epan/filesystem.c | |
parent | 6f540157114bba03a34173f4b3d563e27d6f7498 (diff) |
Include <direct.h> on Windows systems, to declare "mkdir()".
On Windows, put the ".ethereal" directory under the user profile
directory rather than the home directory.
Update the documentation to reflect that, and to fix other out-of-date
information, as well as some typos.
svn path=/trunk/; revision=4068
Diffstat (limited to 'epan/filesystem.c')
-rw-r--r-- | epan/filesystem.c | 57 |
1 files changed, 15 insertions, 42 deletions
diff --git a/epan/filesystem.c b/epan/filesystem.c index 60331ae077..a27016e0bf 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -1,7 +1,7 @@ /* filesystem.c * Filesystem utility routines * - * $Id: filesystem.c,v 1.11 2001/10/23 05:00:59 guy Exp $ + * $Id: filesystem.c,v 1.12 2001/10/23 08:15:11 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -49,6 +49,10 @@ #include <windows.h> #endif +#ifdef HAVE_DIRECT_H +#include <direct.h> /* to declare "mkdir()" on Windows */ +#endif + #ifndef WIN32 #include <pwd.h> #endif @@ -302,11 +306,7 @@ get_systemfile_dir(void) const char * get_persconffile_dir(void) { -#ifdef WIN32 - char *homedrive, *homepath; - char *homestring = NULL; - char *lastsep; -#else +#ifndef WIN32 struct passwd *pwd; #endif char *homedir; @@ -318,40 +318,17 @@ get_persconffile_dir(void) #ifdef WIN32 /* - * XXX - should we use USERPROFILE anywhere in this process? - * Is there a chance that it might be set but one or more of - * HOMEDRIVE or HOMEPATH isn't set? + * Use %USERPROFILE%, so that configuration files are stored + * in the user profile, rather than in the home directory. + * The Windows convention is to store configuration information + * in the user profile, and doing so means you can use + * Ethereal even if the home directory is an inaccessible + * network drive. */ - homedrive = getenv("HOMEDRIVE"); - if (homedrive != NULL) { - homepath = getenv("HOMEPATH"); - if (homepath != NULL) { - /* - * This is cached, so we don't need to worry about - * allocating multiple ones of them. - */ - homestring = - g_malloc(strlen(homedrive) + strlen(homepath) + 1); - strcpy(homestring, homedrive); - strcat(homestring, homepath); - - /* - * Trim off any trailing slash or backslash. - */ - lastsep = find_last_pathname_separator(homestring); - if (lastsep != NULL && *(lastsep + 1) == '\0') { - /* - * Last separator is the last character - * in the string. Nuke it. - */ - *lastsep = '\0'; - } - homedir = homestring; - } else - homedir = homedrive; - } else { + homedir = getenv("USERPROFILE"); + if (homedir == NULL) { /* - * Try using "windir? + * Give up and use "C:". */ homedir = "C:"; } @@ -380,10 +357,6 @@ get_persconffile_dir(void) pf_dir = g_malloc(strlen(homedir) + strlen(PF_DIR) + 2); sprintf(pf_dir, "%s" G_DIR_SEPARATOR_S "%s", homedir, PF_DIR); -#ifdef WIN32 - if (homestring != NULL) - g_free(homestring); -#endif return pf_dir; } |