diff options
author | Michael Vogt <mvo@debian.org> | 2013-12-29 16:04:42 +0100 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2013-12-29 16:04:42 +0100 |
commit | f99a02461efe5183a00d5e73da197b85f93cf57a (patch) | |
tree | 1286d59d9700b4626111347bce45820a7cad6aba /apt-pkg/contrib/fileutl.cc | |
parent | a127de147900050d3dbc3644ed468428749c46fd (diff) | |
parent | 23bd09778261c945b460b46d855b1a6ef998cfd8 (diff) |
Merge remote-tracking branch 'mvo/debian/sid' into debian/sid
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 17 |
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); +} |