Update to get_persdatafile_dir() to choose a default directory on the U3 device that Wireshark is being run from.

The U3 Deployment Guide recommends a sub-directory of U3_DEVICE_DOCUMENT_PATH, so the u3util creates a "My Captures" sub-directory to use as the personal data file directory.


svn path=/trunk/; revision=20441
This commit is contained in:
Graeme Lunt 2007-01-15 19:11:29 +00:00
parent 165354a3f5
commit 4ea1d12df8
2 changed files with 40 additions and 6 deletions

View File

@ -54,6 +54,8 @@
#include "privileges.h"
#include <wiretap/file_util.h>
#define U3_MY_CAPTURES "\\My Captures"
/*
* Given a pathname, return a pointer to the last pathname separator
* character in the pathname, or NULL if the pathname contains no
@ -913,25 +915,43 @@ create_persconffile_dir(char **pf_dir_path_return)
*
* On Win32, this is the "My Documents" folder in the personal profile.
* On UNIX this is simply the current directory.
* On a U3 device this is "$U3_DEVICE_DOCUMENT_PATH\My Captures" folder.
*/
/* XXX - should this and the get_home_dir() be merged? */
/* XXX - is U3 affected somehow? */
extern char *
get_persdatafile_dir(void)
{
#ifdef _WIN32
{
char *u3devicedocumentpath;
TCHAR tszPath[MAX_PATH];
char *szPath;
/* SHGetFolderPath is not available on MSVC 6 - without Platform SDK */
#if 0
HRESULT hrRet;
#else
BOOL bRet;
#endif
/*
* See if we are running in a U3 environment.
*/
u3devicedocumentpath = getenv_utf8("U3_DEVICE_DOCUMENT_PATH");
if (u3devicedocumentpath != NULL) {
/* the "My Captures" sub-directory is created (if it doesn't exist)
by u3util.exe when the U3 Wireshark is first run */
szPath = g_malloc(strlen(u3devicedocumentpath) + strlen(U3_MY_CAPTURES) + 1);
strcpy(szPath, u3devicedocumentpath);
strcat(szPath, U3_MY_CAPTURES);
return szPath;
} else {
#if 0
hrRet = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, tszPath);
if(hrRet == S_OK) {
#else
BOOL bRet;
bRet = SHGetSpecialFolderPath(NULL, tszPath, CSIDL_PERSONAL, FALSE);
if(bRet == TRUE) {
#endif
@ -940,7 +960,7 @@ get_persdatafile_dir(void)
} else {
return "";
}
}
}
#else
return "";
#endif

View File

@ -51,6 +51,8 @@
#define WINPCAP_UNINSTALL "UninstallString"
#define WINPCAP_U3INSTALLED "U3Installed" /* indicate the U3 device that installed WinPcap */
#define MY_CAPTURES "\\My Captures"
#define BUFSIZ 256
static char *extensions[] = {
@ -392,7 +394,7 @@ void disassociate(char *extension)
Configure the host for the U3 Wireshark. This involves:
1) registering the U3 Wireshark with capture file types
2) installing WinPcap if not already installed
3) create a "My Captures" folder on the U3 device if it doesn't already exist
*/
void host_configure(void)
@ -403,8 +405,10 @@ void host_configure(void)
char *u3_host_exec_path;
char *u3_device_exec_path;
char *u3_device_serial;
char *u3_device_document_path;
char wireshark_path[MAX_PATH+1];
char winpcap_path[MAX_PATH+1];
char my_captures_path[MAX_PATH+1];
char reg_key[BUFSIZ];
char buffer[BUFSIZ];
int buflen = BUFSIZ;
@ -494,6 +498,16 @@ void host_configure(void)
}
}
/* CREATE THE "My Captures" FOLDER IF IT DOESN'T ALREADY EXIST */
u3_device_document_path = getenv("U3_DEVICE_DOCUMENT_PATH");
strncpy(my_captures_path, u3_device_document_path, strlen(u3_device_document_path) + 1);
strncat(my_captures_path, MY_CAPTURES, strlen(MY_CAPTURES) + 1);
/* don't care if it succeeds or fails */
(void) CreateDirectory(my_captures_path, NULL);
}
/* host_cleanup