summaryrefslogtreecommitdiff
path: root/epan
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2003-11-02 23:12:35 +0000
committerGerald Combs <gerald@wireshark.org>2003-11-02 23:12:35 +0000
commit031db8b9c87e9f096a377547dfbf6266958fa6cd (patch)
treeb9ceb9b8cc87f48bc800f3b66eb28fb37398cb09 /epan
parentb8d155186ccf09f303c0f7196f09484bf6c9a674 (diff)
downloadwireshark-031db8b9c87e9f096a377547dfbf6266958fa6cd.tar.gz
From Gisle Vanem:
* Added a new function get_file_in_temp() to epan/filesystem.c. This because of asn1.dll plugin which had code to write to a log-file "c:\temp\ethereal.log". I feel this patch makes this safer; I don't even have a c:\temp dir. * Patched packet-asn1.c to use get_file_in_temp(). * Added some #undef to packet-snmp.c to silence gcc. * Changed "%u" -> "%lu" formats in util.c Rename get_file_in_temp() to get_tempfile_path() to match other function names. svn path=/trunk/; revision=8859
Diffstat (limited to 'epan')
-rw-r--r--epan/filesystem.c25
-rw-r--r--epan/filesystem.h11
2 files changed, 34 insertions, 2 deletions
diff --git a/epan/filesystem.c b/epan/filesystem.c
index 2a98c2483b..9857cb1316 100644
--- a/epan/filesystem.c
+++ b/epan/filesystem.c
@@ -1,7 +1,7 @@
/* filesystem.c
* Filesystem utility routines
*
- * $Id: filesystem.c,v 1.24 2003/09/15 19:04:59 guy Exp $
+ * $Id: filesystem.c,v 1.25 2003/11/02 23:12:34 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -627,3 +627,26 @@ deletefile(const char *path)
{
return unlink(path) == 0;
}
+
+/*
+ * Construct and return the path name of a file in the
+ * $TMP/%TEMP% directory.
+ */
+char *get_tempfile_path(const char *file)
+{
+ char path [PATH_MAX], *dir, *def;
+
+#ifdef WIN32
+ dir = getenv("TEMP");
+ def = "C:\\";
+#else
+ dir = getenv("TMP");
+ def = "/tmp";
+#endif
+ if (!dir || (dir = get_dirname(dir)) == NULL)
+ return g_strdup(def);
+
+ snprintf(path, sizeof(path), "%s%c%s", dir, G_DIR_SEPARATOR, file);
+ return g_strdup(path);
+}
+
diff --git a/epan/filesystem.h b/epan/filesystem.h
index a23a621684..d33d24e0c6 100644
--- a/epan/filesystem.h
+++ b/epan/filesystem.h
@@ -1,7 +1,7 @@
/* filesystem.h
* Filesystem utility definitions
*
- * $Id: filesystem.h,v 1.13 2003/05/15 07:44:54 guy Exp $
+ * $Id: filesystem.h,v 1.14 2003/11/02 23:12:34 gerald Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -111,6 +111,15 @@ int create_persconffile_dir(char **pf_dir_path_return);
*/
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.
+ */
+char *get_tempfile_path(const char *filename);
+
+
/* Delete a file */
gboolean deletefile (const char *path);
#endif /* FILESYSTEM_H */