diff options
author | Michael Vogt <mvo@debian.org> | 2013-12-28 00:31:01 +0100 |
---|---|---|
committer | Michael Vogt <mvo@debian.org> | 2013-12-28 00:31:01 +0100 |
commit | 35ac30ee373c5ed84d7c2c5a701ac2d54963504d (patch) | |
tree | 59da7e2385b396052c4f53ac187d520c00d2790c /apt-pkg/contrib/fileutl.cc | |
parent | e5c2b7e8a5455e1dc6993ef9e151b3845fb53c60 (diff) | |
parent | c035b6552ba4bd1c6fba5fd8f8d829c2efbefe3c (diff) |
Merge branch 'debian/sid' into bugfix/bts731738-fancy-progess
Conflicts:
apt-pkg/install-progress.cc
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); +} |