From 02cec4d51b57cfda2636131e89b3b80e4223a881 Mon Sep 17 00:00:00 2001 From: Chris Maynard Date: Fri, 13 Sep 2013 20:15:46 +0000 Subject: [PATCH] Allow an alternate application data location as specified by the new environment variable, WIRESHARK_APPDATA (chosen instead of my originally proposed WS_APPDATA name since most other Wireshark-specific environment variables were already named with the WIRESHARK_ prefix). See also: http://www.wireshark.org/lists/wireshark-users/201309/msg00013.html svn path=/trunk/; revision=52022 --- doc/wireshark.pod.template | 6 ++++++ epan/filesystem.c | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/doc/wireshark.pod.template b/doc/wireshark.pod.template index 28e1ebfc31..8c5365d6b8 100644 --- a/doc/wireshark.pod.template +++ b/doc/wireshark.pod.template @@ -2718,6 +2718,12 @@ See above in the description of the About:Plugins page. =over 4 +=item WIRESHARK_APPDATA + +On Windows, Wireshark normally stores all application data in %APPDATA% or +%USERPROFILE%. You can override the default location by exporting this +environment variable to specify an alternate location. + =item WIRESHARK_DEBUG_EP_NO_CHUNKS Normally per-packet memory is allocated in large "chunks." This behavior diff --git a/epan/filesystem.c b/epan/filesystem.c index d7764b589f..dd5b308bee 100644 --- a/epan/filesystem.c +++ b/epan/filesystem.c @@ -307,7 +307,7 @@ static char *progfile_dir; */ static char *appbundle_dir; #endif - + /* * TRUE if we're running from the build directory and we aren't running * with special privileges. @@ -1320,7 +1320,7 @@ get_persconffile_dir_no_profile(void) #ifdef _WIN32 char *appdatadir; char *userprofiledir; - char *u3appdatapath; + char *altappdatapath; #else const char *homedir; struct passwd *pwd; @@ -1331,15 +1331,24 @@ get_persconffile_dir_no_profile(void) return persconffile_dir; #ifdef _WIN32 + /* + * See if the user has selected an alternate environment. + */ + altappdatapath = getenv_utf8("WIRESHARK_APPDATA"); + if (altappdatapath != NULL) { + persconffile_dir = altappdatapath; + return persconffile_dir; + } + /* * See if we are running in a U3 environment. */ - u3appdatapath = getenv_utf8("U3_APP_DATA_PATH"); - if (u3appdatapath != NULL) { + altappdatapath = getenv_utf8("U3_APP_DATA_PATH"); + if (altappdatapath != NULL) { /* * We are; use the U3 application data path. */ - persconffile_dir = u3appdatapath; + persconffile_dir = altappdatapath; } else { /* * Use %APPDATA% or %USERPROFILE%, so that configuration