summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-01-25 22:39:21 +0100
committerMichael Vogt <mvo@debian.org>2014-01-25 22:39:21 +0100
commit72af508bdbca55d0752aab3369faa1dc944a04e7 (patch)
tree933b60b160f1876990bb02bab20fcdb491c8b560 /apt-pkg/contrib/fileutl.cc
parentb52e8ce26ee0ee906f8bad4dbd72eca51fb65ed7 (diff)
parente093518c03b49a2def83d8b680be4490fed6e69c (diff)
Merge branch 'debian/sid' into ubuntu/master
Conflicts: configure.ac debian/changelog doc/apt-verbatim.ent doc/po/apt-doc.pot po/ar.po po/ast.po po/bg.po po/bs.po po/ca.po po/cs.po po/cy.po po/da.po po/de.po po/dz.po po/el.po po/es.po po/eu.po po/fi.po po/fr.po po/gl.po po/hu.po po/it.po po/ja.po po/km.po po/ko.po po/ku.po po/lt.po po/mr.po po/nb.po po/ne.po po/nl.po po/nn.po po/pl.po po/pt.po po/pt_BR.po po/ro.po po/ru.po po/sk.po po/sl.po po/sv.po po/th.po po/tl.po po/tr.po po/uk.po po/vi.po po/zh_CN.po po/zh_TW.po
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 7fbe4d604..efbf7aaf4 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1827,3 +1827,20 @@ std::vector<std::string> Glob(std::string const &pattern, int flags)
return result;
}
/*}}}*/
+
+std::string GetTempDir()
+{
+ const char *tmpdir = getenv("TMPDIR");
+
+#ifdef P_tmpdir
+ if (!tmpdir)
+ tmpdir = P_tmpdir;
+#endif
+
+ // check that tmpdir is set and exists
+ struct stat st;
+ if (!tmpdir || strlen(tmpdir) == 0 || stat(tmpdir, &st) != 0)
+ tmpdir = "/tmp";
+
+ return string(tmpdir);
+}