on my way to fix #301:
add a function get_persdatafile_dir() that will return the users personal default data dir Win32:"My Documents" UNIX:"" (for the current dir) svn path=/trunk/; revision=20431
This commit is contained in:
parent
d1db2cb464
commit
47aaf7d9b7
|
@ -74,7 +74,7 @@ libwireshark.exp: libwireshark.dll
|
|||
libwireshark.dll: ..\config.h $(LIBWIRESHARK_OBJECTS) libwireshark.def crypt ftypes dfilter $(WSLUA_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
|
||||
crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib dissectors\dissectors.lib $(WSLUA_LIB) ..\image\libwireshark.res
|
||||
@echo Linking libwireshark.dll
|
||||
$(link) $(dlllflags) $(conlibsdll) \
|
||||
$(link) $(dlllflags) $(conlibsdll) shell32.lib \
|
||||
$(LOCAL_LDFLAGS) \
|
||||
/DEF:libwireshark.def /OUT:libwireshark.dll \
|
||||
/IMPLIB:libwireshark.lib $(LIBWIRESHARK_OBJECTS) \
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <shlobj.h>
|
||||
#include "epan/unicode-utils.h"
|
||||
#else
|
||||
#include <pwd.h>
|
||||
|
@ -907,6 +908,36 @@ create_persconffile_dir(char **pf_dir_path_return)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the (default) directory in which personal data is stored.
|
||||
*
|
||||
* On Win32, this is the "My Documents" folder in the personal profile.
|
||||
* On UNIX this is simply the current directory.
|
||||
*/
|
||||
/* XXX - should this and the get_home_dir() be merged? */
|
||||
/* XXX - is U3 affected somehow? */
|
||||
extern char *
|
||||
get_persdatafile_dir(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
{
|
||||
TCHAR tszPath[MAX_PATH];
|
||||
char *szPath;
|
||||
HRESULT hrRet;
|
||||
|
||||
hrRet = SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, tszPath);
|
||||
if(hrRet == S_OK) {
|
||||
szPath = utf_16to8(tszPath);
|
||||
return szPath;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
* Returns the user's home directory on Win32.
|
||||
|
|
|
@ -25,6 +25,104 @@
|
|||
#ifndef FILESYSTEM_H
|
||||
#define FILESYSTEM_H
|
||||
|
||||
/*
|
||||
* Get the pathname of the directory from which the executable came,
|
||||
* and save it for future use. Returns NULL on success, and a
|
||||
* g_mallocated string containing an error on failure.
|
||||
*/
|
||||
extern char *init_progfile_dir(const char *arg0);
|
||||
|
||||
/*
|
||||
* Get the directory in which the program resides.
|
||||
*/
|
||||
extern const char *get_progfile_dir(void);
|
||||
|
||||
/*
|
||||
* Find the directory in which plugins are stored; this must be called
|
||||
* after init_progfile_dir() is called.
|
||||
*/
|
||||
extern void init_plugin_dir(void);
|
||||
|
||||
/*
|
||||
* Get the directory in which plugins are stored.
|
||||
*/
|
||||
extern const char *get_plugin_dir(void);
|
||||
|
||||
/*
|
||||
* Get the flag indicating whether we're running from a build
|
||||
* directory.
|
||||
*/
|
||||
extern gboolean running_in_build_directory(void);
|
||||
|
||||
/*
|
||||
* Get the directory in which global configuration files are
|
||||
* stored.
|
||||
*/
|
||||
extern const char *get_datafile_dir(void);
|
||||
|
||||
/*
|
||||
* Construct the path name of a global configuration file, given the
|
||||
* file name.
|
||||
*/
|
||||
extern char *get_datafile_path(const char *filename);
|
||||
|
||||
/*
|
||||
* Get the directory in which files that, at least on UNIX, are
|
||||
* system files (such as "/etc/ethers") are stored; on Windows,
|
||||
* there's no "/etc" directory, so we get them from the Wireshark
|
||||
* global configuration and data file directory.
|
||||
*/
|
||||
extern const char *get_systemfile_dir(void);
|
||||
|
||||
/*
|
||||
* Create the directory that holds personal configuration files, if
|
||||
* necessary. If we attempted to create it, and failed, return -1 and
|
||||
* set "*pf_dir_path_return" to the pathname of the directory we failed
|
||||
* to create (it's g_mallocated, so our caller should free it); otherwise,
|
||||
* return 0.
|
||||
*/
|
||||
extern int create_persconffile_dir(char **pf_dir_path_return);
|
||||
|
||||
/*
|
||||
* Construct the path name of a personal configuration file, given the
|
||||
* file name.
|
||||
*
|
||||
* On Win32, if "for_writing" is FALSE, we check whether the file exists
|
||||
* and, if not, construct a path name relative to the ".wireshark"
|
||||
* subdirectory of the user's home directory, and check whether that
|
||||
* exists; if it does, we return that, so that configuration files
|
||||
* from earlier versions can be read.
|
||||
*/
|
||||
extern char *get_persconffile_path(const char *filename, gboolean for_writing);
|
||||
|
||||
/*
|
||||
* Get the (default) directory in which personal data is stored.
|
||||
*
|
||||
* On Win32, this is the "My Documents" folder in the personal profile.
|
||||
* On UNIX this is simply the current directory.
|
||||
*/
|
||||
extern char *get_persdatafile_dir(void);
|
||||
|
||||
/*
|
||||
* Construct the path name of a file in $TMP/%TEMP% directory.
|
||||
* Or "/tmp/<filename>" (C:\<filename>) if that fails.
|
||||
*
|
||||
* Return value is malloced so the caller should free it.
|
||||
*/
|
||||
extern char *get_tempfile_path(const char *filename);
|
||||
|
||||
/*
|
||||
* Return an error message for UNIX-style errno indications on open or
|
||||
* create operations.
|
||||
*/
|
||||
extern const char *file_open_error_message(int err, gboolean for_writing);
|
||||
|
||||
/*
|
||||
* Return an error message for UNIX-style errno indications on write
|
||||
* operations.
|
||||
*/
|
||||
extern const char *file_write_error_message(int err);
|
||||
|
||||
/*
|
||||
* Given a pathname, return the last component.
|
||||
*/
|
||||
|
@ -63,99 +161,9 @@ extern int test_for_directory(const char *);
|
|||
*/
|
||||
extern int test_for_fifo(const char *);
|
||||
|
||||
/*
|
||||
* Get the pathname of the directory from which the executable came,
|
||||
* and save it for future use. Returns NULL on success, and a
|
||||
* g_mallocated string containing an error on failure.
|
||||
*/
|
||||
extern char *init_progfile_dir(const char *arg0);
|
||||
|
||||
/*
|
||||
* Get the directory in which the program resides.
|
||||
*/
|
||||
extern const char *get_progfile_dir(void);
|
||||
|
||||
/*
|
||||
* Get the directory in which global configuration and data files are
|
||||
* stored.
|
||||
*/
|
||||
extern const char *get_datafile_dir(void);
|
||||
|
||||
/*
|
||||
* Find the directory in which plugins are stored; this must be called
|
||||
* after init_progfile_dir() is called.
|
||||
*/
|
||||
extern void init_plugin_dir(void);
|
||||
|
||||
/*
|
||||
* Get the directory in which plugins are stored.
|
||||
*/
|
||||
extern const char *get_plugin_dir(void);
|
||||
|
||||
/*
|
||||
* Get the flag indicating whether we're running from a build
|
||||
* directory.
|
||||
*/
|
||||
extern gboolean running_in_build_directory(void);
|
||||
|
||||
/*
|
||||
* Construct the path name of a global configuration file, given the
|
||||
* file name.
|
||||
*/
|
||||
extern char *get_datafile_path(const char *filename);
|
||||
|
||||
/*
|
||||
* Get the directory in which files that, at least on UNIX, are
|
||||
* system files (such as "/etc/ethers") are stored; on Windows,
|
||||
* there's no "/etc" directory, so we get them from the Wireshark
|
||||
* global configuration and data file directory.
|
||||
*/
|
||||
extern const char *get_systemfile_dir(void);
|
||||
|
||||
/*
|
||||
* Create the directory that holds personal configuration files, if
|
||||
* necessary. If we attempted to create it, and failed, return -1 and
|
||||
* set "*pf_dir_path_return" to the pathname of the directory we failed
|
||||
* to create (it's g_mallocated, so our caller should free it); otherwise,
|
||||
* return 0.
|
||||
*/
|
||||
extern int create_persconffile_dir(char **pf_dir_path_return);
|
||||
|
||||
/*
|
||||
* Construct the path name of a personal configuration file, given the
|
||||
* file name.
|
||||
*
|
||||
* On Win32, if "for_writing" is FALSE, we check whether the file exists
|
||||
* and, if not, construct a path name relative to the ".wireshark"
|
||||
* subdirectory of the user's home directory, and check whether that
|
||||
* exists; if it does, we return that, so that configuration files
|
||||
* from earlier versions can be read.
|
||||
*/
|
||||
extern char *get_persconffile_path(const char *filename, gboolean for_writing);
|
||||
|
||||
/*
|
||||
* Construct the path name of a file in $TMP/%TEMP% directory.
|
||||
* Or "/tmp/<filename>" (C:\<filename>) if that fails.
|
||||
*
|
||||
* Return value is malloced so the caller should free it.
|
||||
*/
|
||||
extern char *get_tempfile_path(const char *filename);
|
||||
|
||||
/* Delete a file */
|
||||
extern gboolean deletefile (const char *path);
|
||||
|
||||
/*
|
||||
* Return an error message for UNIX-style errno indications on open or
|
||||
* create operations.
|
||||
*/
|
||||
extern const char *file_open_error_message(int err, gboolean for_writing);
|
||||
|
||||
/*
|
||||
* Return an error message for UNIX-style errno indications on write
|
||||
* operations.
|
||||
*/
|
||||
extern const char *file_write_error_message(int err);
|
||||
|
||||
/*
|
||||
* Check, if file is existing.
|
||||
*/
|
||||
|
|
|
@ -370,6 +370,7 @@ get_manuf_name_if_known
|
|||
get_oid_name
|
||||
get_oid_str_name
|
||||
get_persconffile_path
|
||||
get_persdatafile_dir
|
||||
get_plugin_dir
|
||||
get_plugins_pers_dir
|
||||
get_progfile_dir
|
||||
|
|
Loading…
Reference in New Issue