|
Peter Hatina |
fe8eca |
commit b32de2f6e35b4e7d6ea4d0477db91b12861c09d6
|
|
Peter Hatina |
fe8eca |
Author: Peter Hatina <phatina@gmail.com>
|
|
Peter Hatina |
fe8eca |
Date: Tue Jan 12 13:56:59 2016 +0100
|
|
|
c06811 |
|
|
Peter Hatina |
fe8eca |
Move default temporary directory to /var/tmp
|
|
|
d3e571 |
|
|
Peter Hatina |
fe8eca |
diff --git a/ui/gtk/about_dlg.c b/ui/gtk/about_dlg.c
|
|
Peter Hatina |
fe8eca |
index 0ed474a..fb3275b 100644
|
|
Peter Hatina |
fe8eca |
--- a/ui/gtk/about_dlg.c
|
|
Peter Hatina |
fe8eca |
+++ b/ui/gtk/about_dlg.c
|
|
Peter Hatina |
fe8eca |
@@ -30,6 +30,7 @@
|
|
Peter Hatina |
fe8eca |
#include <wsutil/filesystem.h>
|
|
Peter Hatina |
fe8eca |
#include <wsutil/copyright_info.h>
|
|
Peter Hatina |
fe8eca |
#include <wsutil/ws_version_info.h>
|
|
Peter Hatina |
fe8eca |
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
Peter Hatina |
fe8eca |
#ifdef HAVE_LIBSMI
|
|
Peter Hatina |
fe8eca |
#include <epan/oids.h>
|
|
Peter Hatina |
fe8eca |
#endif
|
|
Peter Hatina |
fe8eca |
@@ -407,7 +408,7 @@ about_folders_page_new(void)
|
|
Peter Hatina |
fe8eca |
"capture files");
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
/* temp */
|
|
Peter Hatina |
fe8eca |
- about_folders_row(table, "Temp", g_get_tmp_dir(),
|
|
Peter Hatina |
fe8eca |
+ about_folders_row(table, "Temp", get_tmp_dir(),
|
|
Peter Hatina |
fe8eca |
"untitled capture files");
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
/* pers conf */
|
|
|
d3e571 |
diff --git a/ui/gtk/proto_help.c b/ui/gtk/proto_help.c
|
|
Peter Hatina |
fe8eca |
index 79cafd4..47eec6c 100644
|
|
|
d3e571 |
--- a/ui/gtk/proto_help.c
|
|
|
d3e571 |
+++ b/ui/gtk/proto_help.c
|
|
Peter Hatina |
fe8eca |
@@ -37,6 +37,8 @@
|
|
Peter Hatina |
fe8eca |
#include "../file.h"
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
1fba24 |
|
|
Peter Hatina |
1fba24 |
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
Peter Hatina |
1fba24 |
+
|
|
|
d3e571 |
#include "ui/gtk/proto_help.h"
|
|
Peter Hatina |
1fba24 |
|
|
Peter Hatina |
1fba24 |
/*
|
|
Peter Hatina |
fe8eca |
@@ -155,7 +157,7 @@ void proto_help_init(void)
|
|
|
d3e571 |
/* Start loop */
|
|
|
d3e571 |
|
|
|
d3e571 |
#ifdef PH_DEBUG_LOG
|
|
|
d3e571 |
- ph_log_path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", g_get_tmp_dir(), PH_FILE_LOG);
|
|
|
d3e571 |
+ ph_log_path = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", get_tmp_dir(), PH_FILE_LOG);
|
|
|
d3e571 |
#endif
|
|
|
d3e571 |
|
|
|
d3e571 |
for (i = 0; i < PH_CONF_DIRS; i++) {
|
|
Peter Hatina |
fe8eca |
diff --git a/ui/qt/about_dialog.cpp b/ui/qt/about_dialog.cpp
|
|
Peter Hatina |
fe8eca |
index c0899a0..4fada89 100644
|
|
Peter Hatina |
fe8eca |
--- a/ui/qt/about_dialog.cpp
|
|
Peter Hatina |
fe8eca |
+++ b/ui/qt/about_dialog.cpp
|
|
Peter Hatina |
fe8eca |
@@ -49,6 +49,7 @@
|
|
Peter Hatina |
fe8eca |
#include "file.h"
|
|
Peter Hatina |
fe8eca |
#include "wsutil/file_util.h"
|
|
Peter Hatina |
fe8eca |
#include "wsutil/tempfile.h"
|
|
Peter Hatina |
fe8eca |
+#include "wsutil/wstmpdir.h" /* for get_tmp_dir() */
|
|
Peter Hatina |
fe8eca |
#include "wsutil/plugins.h"
|
|
Peter Hatina |
fe8eca |
#include "wsutil/copyright_info.h"
|
|
Peter Hatina |
fe8eca |
#include "wsutil/ws_version_info.h"
|
|
Peter Hatina |
fe8eca |
@@ -184,7 +185,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
|
|
Peter Hatina |
fe8eca |
message += about_folders_row("\"File\" dialogs", get_last_open_dir(), "capture files");
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
/* temp */
|
|
Peter Hatina |
fe8eca |
- message += about_folders_row("Temp", g_get_tmp_dir(), "untitled capture files");
|
|
Peter Hatina |
fe8eca |
+ message += about_folders_row("Temp", get_tmp_dir(), "untitled capture files");
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
/* pers conf */
|
|
Peter Hatina |
fe8eca |
message += about_folders_row("Personal configuration",
|
|
Peter Hatina |
fe8eca |
diff --git a/ui/qt/iax2_analysis_dialog.cpp b/ui/qt/iax2_analysis_dialog.cpp
|
|
Peter Hatina |
fe8eca |
index e1ef186..b672b31 100644
|
|
Peter Hatina |
fe8eca |
--- a/ui/qt/iax2_analysis_dialog.cpp
|
|
Peter Hatina |
fe8eca |
+++ b/ui/qt/iax2_analysis_dialog.cpp
|
|
Peter Hatina |
fe8eca |
@@ -41,6 +41,8 @@
|
|
Peter Hatina |
fe8eca |
#include <wsutil/g711.h>
|
|
Peter Hatina |
fe8eca |
#include <wsutil/pint.h>
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
Peter Hatina |
fe8eca |
+
|
|
Peter Hatina |
fe8eca |
#include <QFileDialog>
|
|
Peter Hatina |
fe8eca |
#include <QMessageBox>
|
|
Peter Hatina |
fe8eca |
#include <QPushButton>
|
|
Peter Hatina |
fe8eca |
@@ -271,10 +273,10 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
// We keep our temp files open for the lifetime of the dialog. The GTK+
|
|
Peter Hatina |
fe8eca |
// UI opens and closes at various points.
|
|
Peter Hatina |
fe8eca |
- QString tempname = QString("%1/wireshark_iax2_f").arg(QDir::tempPath());
|
|
Peter Hatina |
fe8eca |
+ QString tempname = QString("%1/wireshark_iax2_f").arg(get_tmp_dir());
|
|
Peter Hatina |
fe8eca |
fwd_tempfile_ = new QTemporaryFile(tempname, this);
|
|
Peter Hatina |
fe8eca |
fwd_tempfile_->open();
|
|
Peter Hatina |
fe8eca |
- tempname = QString("%1/wireshark_iax2_r").arg(QDir::tempPath());
|
|
Peter Hatina |
fe8eca |
+ tempname = QString("%1/wireshark_iax2_r").arg(get_tmp_dir());
|
|
Peter Hatina |
fe8eca |
rev_tempfile_ = new QTemporaryFile(tempname, this);
|
|
Peter Hatina |
fe8eca |
rev_tempfile_->open();
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp
|
|
Peter Hatina |
fe8eca |
index 87322df..fbe9ffa 100644
|
|
Peter Hatina |
fe8eca |
--- a/ui/qt/rtp_analysis_dialog.cpp
|
|
Peter Hatina |
fe8eca |
+++ b/ui/qt/rtp_analysis_dialog.cpp
|
|
Peter Hatina |
fe8eca |
@@ -38,6 +38,8 @@
|
|
Peter Hatina |
fe8eca |
#include <wsutil/g711.h>
|
|
Peter Hatina |
fe8eca |
#include <wsutil/pint.h>
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
Peter Hatina |
fe8eca |
+
|
|
Peter Hatina |
fe8eca |
#include <QFileDialog>
|
|
Peter Hatina |
fe8eca |
#include <QMessageBox>
|
|
Peter Hatina |
fe8eca |
#include <QPushButton>
|
|
Peter Hatina |
fe8eca |
@@ -321,10 +323,10 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf, struct _r
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
// We keep our temp files open for the lifetime of the dialog. The GTK+
|
|
Peter Hatina |
fe8eca |
// UI opens and closes at various points.
|
|
Peter Hatina |
fe8eca |
- QString tempname = QString("%1/wireshark_rtp_f").arg(QDir::tempPath());
|
|
Peter Hatina |
fe8eca |
+ QString tempname = QString("%1/wireshark_rtp_f").arg(get_tmp_dir());
|
|
Peter Hatina |
fe8eca |
fwd_tempfile_ = new QTemporaryFile(tempname, this);
|
|
Peter Hatina |
fe8eca |
fwd_tempfile_->open();
|
|
Peter Hatina |
fe8eca |
- tempname = QString("%1/wireshark_rtp_r").arg(QDir::tempPath());
|
|
Peter Hatina |
fe8eca |
+ tempname = QString("%1/wireshark_rtp_r").arg(get_tmp_dir());
|
|
Peter Hatina |
fe8eca |
rev_tempfile_ = new QTemporaryFile(tempname, this);
|
|
Peter Hatina |
fe8eca |
rev_tempfile_->open();
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
diff --git a/ui/qt/rtp_audio_stream.cpp b/ui/qt/rtp_audio_stream.cpp
|
|
Peter Hatina |
fe8eca |
index 1346a4d..4d34a3b 100644
|
|
Peter Hatina |
fe8eca |
--- a/ui/qt/rtp_audio_stream.cpp
|
|
Peter Hatina |
fe8eca |
+++ b/ui/qt/rtp_audio_stream.cpp
|
|
Peter Hatina |
fe8eca |
@@ -33,6 +33,7 @@
|
|
Peter Hatina |
fe8eca |
#include <ui/rtp_stream.h>
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
#include <wsutil/nstime.h>
|
|
Peter Hatina |
fe8eca |
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
#include <QAudioFormat>
|
|
Peter Hatina |
fe8eca |
#include <QAudioOutput>
|
|
Peter Hatina |
fe8eca |
@@ -71,7 +72,7 @@ RtpAudioStream::RtpAudioStream(QObject *parent, _rtp_stream_info *rtp_stream) :
|
|
Peter Hatina |
fe8eca |
visual_sample_rate_, SPEEX_RESAMPLER_QUALITY_MIN, NULL);
|
|
Peter Hatina |
fe8eca |
ws_codec_resampler_skip_zeros(visual_resampler_);
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
- QString tempname = QString("%1/wireshark_rtp_stream").arg(QDir::tempPath());
|
|
Peter Hatina |
fe8eca |
+ QString tempname = QString("%1/wireshark_rtp_stream").arg(get_tmp_dir());
|
|
Peter Hatina |
fe8eca |
tempfile_ = new QTemporaryFile(tempname, this);
|
|
Peter Hatina |
fe8eca |
tempfile_->open();
|
|
Peter Hatina |
fe8eca |
|
|
|
d3e571 |
diff --git a/wsutil/Makefile.common b/wsutil/Makefile.common
|
|
Peter Hatina |
fe8eca |
index e24f015..49f0a95 100644
|
|
|
d3e571 |
--- a/wsutil/Makefile.common
|
|
|
d3e571 |
+++ b/wsutil/Makefile.common
|
|
Peter Hatina |
fe8eca |
@@ -71,7 +71,8 @@ LIBWSUTIL_SRC = \
|
|
Peter Hatina |
fe8eca |
ws_mempbrk.c \
|
|
|
d3e571 |
u3.c \
|
|
Peter Hatina |
fe8eca |
unicode-utils.c \
|
|
Peter Hatina |
fe8eca |
- ws_version_info.c
|
|
Peter Hatina |
fe8eca |
+ ws_version_info.c \
|
|
|
d3e571 |
+ wstmpdir.c
|
|
|
d3e571 |
|
|
Peter Hatina |
fe8eca |
# Header files that don't declare replacement functions for functions
|
|
Peter Hatina |
fe8eca |
# present in the APIs/ABIs of some, but not all, targets.
|
|
Peter Hatina |
fe8eca |
@@ -128,7 +129,8 @@ libwsutil_nonrepl_INCLUDES = \
|
|
Peter Hatina |
fe8eca |
ws_diag_control.h \
|
|
Peter Hatina |
fe8eca |
ws_mempbrk.h \
|
|
Peter Hatina |
fe8eca |
ws_mempbrk_int.h \
|
|
Peter Hatina |
fe8eca |
- ws_version_info.h
|
|
Peter Hatina |
fe8eca |
+ ws_version_info.h \
|
|
|
d3e571 |
+ wstmpdir.h
|
|
Peter Hatina |
05ceca |
|
|
Peter Hatina |
fe8eca |
# Header files that are not generated from other files
|
|
Peter Hatina |
fe8eca |
LIBWSUTIL_INCLUDES = \
|
|
|
d3e571 |
diff --git a/wsutil/tempfile.c b/wsutil/tempfile.c
|
|
Peter Hatina |
fe8eca |
index 93bd66f..757b6c8 100644
|
|
|
d3e571 |
--- a/wsutil/tempfile.c
|
|
|
d3e571 |
+++ b/wsutil/tempfile.c
|
|
Peter Hatina |
fe8eca |
@@ -44,6 +44,7 @@
|
|
Peter Hatina |
1fba24 |
|
|
Peter Hatina |
1fba24 |
#include "tempfile.h"
|
|
Peter Hatina |
1fba24 |
#include <wsutil/file_util.h>
|
|
Peter Hatina |
fe8eca |
+#include <wsutil/wstmpdir.h> /* for get_tmp_dir() */
|
|
Peter Hatina |
1fba24 |
|
|
Peter Hatina |
1fba24 |
#ifndef __set_errno
|
|
Peter Hatina |
1fba24 |
#define __set_errno(x) errno=(x)
|
|
Peter Hatina |
fe8eca |
@@ -146,7 +147,7 @@ mkdtemp (char *path_template)
|
|
|
d3e571 |
*/
|
|
|
d3e571 |
char *get_tempfile_path(const char *filename)
|
|
|
d3e571 |
{
|
|
Peter Hatina |
fe8eca |
- return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", g_get_tmp_dir(), filename);
|
|
Peter Hatina |
fe8eca |
+ return g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s", get_tmp_dir(), filename);
|
|
|
d3e571 |
}
|
|
|
d3e571 |
|
|
|
d3e571 |
#define MAX_TEMPFILES 3
|
|
Peter Hatina |
fe8eca |
@@ -203,7 +204,7 @@ create_tempfile(char **namebuf, const char *pfx)
|
|
Peter Hatina |
fe8eca |
tf[idx].path = (char *)g_malloc(tf[idx].len);
|
|
Peter Hatina |
fe8eca |
}
|
|
|
d3e571 |
|
|
Peter Hatina |
fe8eca |
- tmp_dir = g_get_tmp_dir();
|
|
Peter Hatina |
fe8eca |
+ tmp_dir = get_tmp_dir();
|
|
Peter Hatina |
1fba24 |
|
|
Peter Hatina |
1fba24 |
#ifdef _WIN32
|
|
Peter Hatina |
fe8eca |
_tzset();
|
|
Peter Hatina |
fe8eca |
@@ -237,7 +238,7 @@ create_tempfile(char **namebuf, const char *pfx)
|
|
Peter Hatina |
1fba24 |
|
|
Peter Hatina |
1fba24 |
/**
|
|
Peter Hatina |
1fba24 |
* Create a directory with the given prefix (e.g. "wireshark"). The path
|
|
Peter Hatina |
1fba24 |
- * is created using g_get_tmp_dir and mkdtemp.
|
|
Peter Hatina |
1fba24 |
+ * is created using get_tmp_dir and mkdtemp.
|
|
Peter Hatina |
1fba24 |
*
|
|
Peter Hatina |
1fba24 |
* @param namebuf
|
|
Peter Hatina |
1fba24 |
* @param pfx A prefix for the temporary directory.
|
|
Peter Hatina |
fe8eca |
@@ -265,7 +266,7 @@ create_tempdir(char **namebuf, const char *pfx)
|
|
Peter Hatina |
fe8eca |
/*
|
|
Peter Hatina |
fe8eca |
* We can't use get_tempfile_path here because we're called from dumpcap.c.
|
|
Peter Hatina |
fe8eca |
*/
|
|
Peter Hatina |
fe8eca |
- tmp_dir = g_get_tmp_dir();
|
|
Peter Hatina |
fe8eca |
+ tmp_dir = get_tmp_dir();
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
while (g_snprintf(td_path[idx], td_path_len[idx], "%s%c%s" TMP_FILE_SUFFIX, tmp_dir, G_DIR_SEPARATOR, pfx) > td_path_len[idx]) {
|
|
Peter Hatina |
fe8eca |
td_path_len[idx] *= 2;
|
|
Peter Hatina |
fe8eca |
diff --git a/wsutil/tempfile.h b/wsutil/tempfile.h
|
|
Peter Hatina |
fe8eca |
index f595632..5e22227 100644
|
|
Peter Hatina |
fe8eca |
--- a/wsutil/tempfile.h
|
|
Peter Hatina |
fe8eca |
+++ b/wsutil/tempfile.h
|
|
Peter Hatina |
fe8eca |
@@ -45,7 +45,7 @@ WS_DLL_PUBLIC char *get_tempfile_path(const char *filename);
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
/**
|
|
Peter Hatina |
fe8eca |
* Create a tempfile with the given prefix (e.g. "wireshark"). The path
|
|
Peter Hatina |
fe8eca |
- * is created using g_get_tmp_dir and mkstemp.
|
|
Peter Hatina |
fe8eca |
+ * is created using get_tmp_dir and mkstemp.
|
|
Peter Hatina |
fe8eca |
*
|
|
Peter Hatina |
fe8eca |
* @param namebuf [in,out] If not NULL, receives the full path of the temp file.
|
|
Peter Hatina |
fe8eca |
* Must NOT be freed.
|
|
Peter Hatina |
fe8eca |
@@ -56,7 +56,7 @@ WS_DLL_PUBLIC int create_tempfile(char **namebuf, const char *pfx);
|
|
Peter Hatina |
fe8eca |
|
|
Peter Hatina |
fe8eca |
/**
|
|
Peter Hatina |
fe8eca |
* Create a directory with the given prefix (e.g. "wireshark"). The path
|
|
Peter Hatina |
fe8eca |
- * is created using g_get_tmp_dir and mkdtemp.
|
|
Peter Hatina |
fe8eca |
+ * is created using get_tmp_dir and mkdtemp.
|
|
Peter Hatina |
fe8eca |
*
|
|
Peter Hatina |
fe8eca |
* @param namebuf If not NULL, receives the full path of the temp directory.
|
|
Peter Hatina |
fe8eca |
* Must NOT be freed.
|
|
Peter Hatina |
1fba24 |
diff --git a/wsutil/wstmpdir.c b/wsutil/wstmpdir.c
|
|
Peter Hatina |
1fba24 |
new file mode 100644
|
|
Peter Hatina |
1fba24 |
index 0000000..d8b733b
|
|
Peter Hatina |
1fba24 |
--- /dev/null
|
|
Peter Hatina |
1fba24 |
+++ b/wsutil/wstmpdir.c
|
|
Peter Hatina |
1fba24 |
@@ -0,0 +1,70 @@
|
|
Peter Hatina |
1fba24 |
+/* wstmpdir.c
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Copyright (C) 2013 Red Hat, Inc. All right reserved.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Temporary directory routine
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * This program is free software; you can redistribute it and/or
|
|
Peter Hatina |
1fba24 |
+ * modify it under the terms of the GNU General Public License
|
|
Peter Hatina |
1fba24 |
+ * as published by the Free Software Foundation; either version 2
|
|
Peter Hatina |
1fba24 |
+ * of the License, or (at your option) any later version.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * This program is distributed in the hope that it will be useful,
|
|
Peter Hatina |
1fba24 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Peter Hatina |
1fba24 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Peter Hatina |
1fba24 |
+ * GNU General Public License for more details.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * You should have received a copy of the GNU General Public License
|
|
Peter Hatina |
1fba24 |
+ * along with this program; if not, write to the Free Software
|
|
Peter Hatina |
1fba24 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Author: Peter Hatina <phatina@redhat.com>
|
|
Peter Hatina |
1fba24 |
+ */
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#include "config.h"
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#include <glib.h>
|
|
Peter Hatina |
1fba24 |
+#include "wstmpdir.h"
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+/**
|
|
Peter Hatina |
1fba24 |
+ * Gets the directory to use for temporary files.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Inspired by glib-2.0. If no TMP, TEMP or TMPDIR is set,
|
|
Peter Hatina |
1fba24 |
+ * /var/tmp is returned (Fedora specific).
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Returns: the directory to use for temporary files.
|
|
Peter Hatina |
1fba24 |
+ */
|
|
Peter Hatina |
1fba24 |
+const char *get_tmp_dir(void)
|
|
Peter Hatina |
1fba24 |
+{
|
|
Peter Hatina |
1fba24 |
+ static gchar *tmp_dir;
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+ if (g_once_init_enter(&tmp_dir)) {
|
|
Peter Hatina |
1fba24 |
+ gchar *tmp;
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+ tmp = g_strdup(g_getenv("TEMP"));
|
|
Peter Hatina |
1fba24 |
+ if (tmp == NULL || *tmp == '\0') {
|
|
Peter Hatina |
1fba24 |
+ g_free(tmp);
|
|
Peter Hatina |
1fba24 |
+ tmp = g_strdup(g_getenv("TMPDIR"));
|
|
Peter Hatina |
1fba24 |
+ }
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#ifdef P_tmpdir
|
|
Peter Hatina |
1fba24 |
+ if (tmp == NULL || *tmp == '\0') {
|
|
Peter Hatina |
1fba24 |
+ gsize k;
|
|
Peter Hatina |
1fba24 |
+ g_free(tmp);
|
|
Peter Hatina |
1fba24 |
+ tmp = g_strdup(P_tmpdir);
|
|
Peter Hatina |
1fba24 |
+ k = strlen(tmp);
|
|
Peter Hatina |
1fba24 |
+ if (k > 1 && G_IS_DIR_SEPARATOR(tmp[k - 1]))
|
|
Peter Hatina |
1fba24 |
+ tmp[k - 1] = '\0';
|
|
Peter Hatina |
1fba24 |
+ }
|
|
Peter Hatina |
1fba24 |
+#endif /* P_tmpdir */
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+ if (tmp == NULL || *tmp == '\0') {
|
|
Peter Hatina |
1fba24 |
+ g_free(tmp);
|
|
Peter Hatina |
1fba24 |
+ tmp = g_strdup("/var/tmp");
|
|
Peter Hatina |
1fba24 |
+ }
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+ g_once_init_leave(&tmp_dir, tmp);
|
|
Peter Hatina |
1fba24 |
+ }
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+ return tmp_dir;
|
|
Peter Hatina |
1fba24 |
+}
|
|
Peter Hatina |
1fba24 |
diff --git a/wsutil/wstmpdir.h b/wsutil/wstmpdir.h
|
|
Peter Hatina |
1fba24 |
new file mode 100644
|
|
Peter Hatina |
1fba24 |
index 0000000..021b615
|
|
Peter Hatina |
1fba24 |
--- /dev/null
|
|
Peter Hatina |
1fba24 |
+++ b/wsutil/wstmpdir.h
|
|
Peter Hatina |
1fba24 |
@@ -0,0 +1,39 @@
|
|
Peter Hatina |
1fba24 |
+/* wstmpdir.c
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Copyright (C) 2013 Red Hat, Inc. All right reserved.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Temporary directory routine
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * This program is free software; you can redistribute it and/or
|
|
Peter Hatina |
1fba24 |
+ * modify it under the terms of the GNU General Public License
|
|
Peter Hatina |
1fba24 |
+ * as published by the Free Software Foundation; either version 2
|
|
Peter Hatina |
1fba24 |
+ * of the License, or (at your option) any later version.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * This program is distributed in the hope that it will be useful,
|
|
Peter Hatina |
1fba24 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Peter Hatina |
1fba24 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Peter Hatina |
1fba24 |
+ * GNU General Public License for more details.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * You should have received a copy of the GNU General Public License
|
|
Peter Hatina |
1fba24 |
+ * along with this program; if not, write to the Free Software
|
|
Peter Hatina |
1fba24 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
Peter Hatina |
1fba24 |
+ *
|
|
Peter Hatina |
1fba24 |
+ * Author: Peter Hatina <phatina@redhat.com>
|
|
Peter Hatina |
1fba24 |
+ */
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#ifndef __WS_TMP_DIR_H__
|
|
Peter Hatina |
1fba24 |
+#define __WS_TMP_DIR_H__
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#include "ws_symbol_export.h"
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#ifdef __cplusplus
|
|
Peter Hatina |
1fba24 |
+extern "C" {
|
|
Peter Hatina |
1fba24 |
+#endif // __cplusplus
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+WS_DLL_PUBLIC const char *get_tmp_dir(void);
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#ifdef __cplusplus
|
|
Peter Hatina |
1fba24 |
+}
|
|
Peter Hatina |
1fba24 |
+#endif // __cplusplus
|
|
Peter Hatina |
1fba24 |
+
|
|
Peter Hatina |
1fba24 |
+#endif // __WS_TMP_DIR_H__
|