]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/fileutl.cc
Merge branch 'debian/sid' into feature/source-deb822
[apt.git] / apt-pkg / contrib / fileutl.cc
index 7fbe4d604da276033d0de7c2e0ff08231d78e02e..efbf7aaf4c2300ac61d309c63465efb67a4430b3 100644 (file)
@@ -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);
+}