on my way to fix #301:
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 14 Jan 2007 22:25:22 +0000 (22:25 +0000)
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 14 Jan 2007 22:25:22 +0000 (22:25 +0000)
add a function get_persdatafile_dir() that will return the users personal default data dir Win32:"My Documents" UNIX:"" (for the current dir)

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@20431 f5534014-38df-0310-8fa8-9805f1628bb7

epan/Makefile.nmake
epan/filesystem.c
epan/filesystem.h
epan/libwireshark.def

index 6915cacae88034e14c57ad0a6c01ed29ea783ce6..fcf9622516308aacb09b9e79c214671d7e4e6c0e 100644 (file)
@@ -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) \
index e81def0a034c92c716ae7043f0218a52f694c680..b4cfaf5ef251f684f58447702a856dc3d4c1afd9 100644 (file)
@@ -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.
index 9f5356a39c14093bace380c3341218f524ce39c8..47e6b95d34654e9870b80df546f9bf080a4387ac 100644 (file)
 #ifndef FILESYSTEM_H
 #define FILESYSTEM_H
 
-/*
- * Given a pathname, return the last component.
- */
-extern const char *get_basename(const char *);
-
-/*
- * Given a pathname, return a string containing everything but the
- * last component.  NOTE: this overwrites the pathname handed into
- * it....
- */
-extern char *get_dirname(char *);
-
-/*
- * Given a pathname, return:
- *
- *     the errno, if an attempt to "stat()" the file fails;
- *
- *     EISDIR, if the attempt succeeded and the file turned out
- *     to be a directory;
- *
- *     0, if the attempt succeeded and the file turned out not
- *     to be a directory.
- */
-extern int test_for_directory(const char *);
-
-/*
- * Given a pathname, return:
- *
- *     the errno, if an attempt to "stat()" the file fails;
- *
- *     ESPIPE, if the attempt succeeded and the file turned out
- *     to be a FIFO;
- *
- *     0, if the attempt succeeded and the file turned out not
- *     to be a FIFO.
- */
-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
@@ -75,12 +37,6 @@ extern char *init_progfile_dir(const char *arg0);
  */
 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.
@@ -98,6 +54,12 @@ extern const char *get_plugin_dir(void);
  */
 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.
@@ -133,6 +95,14 @@ extern int create_persconffile_dir(char **pf_dir_path_return);
  */
 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.
@@ -141,9 +111,6 @@ extern char *get_persconffile_path(const char *filename, gboolean for_writing);
  */
 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.
@@ -156,6 +123,47 @@ extern const char *file_open_error_message(int err, gboolean for_writing);
  */
 extern const char *file_write_error_message(int err);
 
+/*
+ * Given a pathname, return the last component.
+ */
+extern const char *get_basename(const char *);
+
+/*
+ * Given a pathname, return a string containing everything but the
+ * last component.  NOTE: this overwrites the pathname handed into
+ * it....
+ */
+extern char *get_dirname(char *);
+
+/*
+ * Given a pathname, return:
+ *
+ *     the errno, if an attempt to "stat()" the file fails;
+ *
+ *     EISDIR, if the attempt succeeded and the file turned out
+ *     to be a directory;
+ *
+ *     0, if the attempt succeeded and the file turned out not
+ *     to be a directory.
+ */
+extern int test_for_directory(const char *);
+
+/*
+ * Given a pathname, return:
+ *
+ *     the errno, if an attempt to "stat()" the file fails;
+ *
+ *     ESPIPE, if the attempt succeeded and the file turned out
+ *     to be a FIFO;
+ *
+ *     0, if the attempt succeeded and the file turned out not
+ *     to be a FIFO.
+ */
+extern int test_for_fifo(const char *);
+
+/* Delete a file */
+extern gboolean deletefile (const char *path);
+
 /*
  * Check, if file is existing.
  */
index dbfe810ee28e00d047b42b0151a93e6559160984..68d43884f12761a0abbcc2380e5f78cb26a8db31 100644 (file)
@@ -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