]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Make bsdtar_test and bsdcpio_test aware of TMPDIR/TMP/TEMPDIR
authorTim Kientzle <kientzle@gmail.com>
Thu, 18 Jun 2009 05:11:18 +0000 (01:11 -0400)
committerTim Kientzle <kientzle@gmail.com>
Thu, 18 Jun 2009 05:11:18 +0000 (01:11 -0400)
environment variables.

SVN-Revision: 1170

cpio/test/main.c
tar/test/main.c

index 08a010b705bd8b374d3c30cef07c0eb1466be604..e8b8a3d61604c3864c6441e9c8f2da01201a8470 100644 (file)
@@ -990,6 +990,7 @@ int main(int argc, char **argv)
        char *testprg;
 #endif
        const char *opt_arg, *progname, *p;
+       char *tmp;
        char tmpdir[256];
        char tmpdir_timestamp[256];
 
@@ -1018,6 +1019,17 @@ int main(int argc, char **argv)
        testprog = getenv(ENVBASE);
 #endif
 
+       if (getenv("TMPDIR") != NULL)
+               tmp = getenv("TMPDIR");
+       else if (getenv("TMP") != NULL)
+               tmp = getenv("TMP");
+       else if (getenv("TEMP") != NULL)
+               tmp = getenv("TEMP");
+       else if (getenv("TEMPDIR") != NULL)
+               tmp = getenv("TEMPDIR");
+       else
+               tmp = "/tmp";
+
        /* Allow -d to be controlled through the environment. */
        if (getenv(ENVBASE "_DEBUG") != NULL)
                dump_on_failure = 1;
@@ -1112,7 +1124,8 @@ int main(int argc, char **argv)
                strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp),
                    "%Y-%m-%dT%H.%M.%S",
                    localtime(&now));
-               sprintf(tmpdir, "/tmp/%s.%s-%03d", progname, tmpdir_timestamp, i);
+               sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname,
+                   tmpdir_timestamp, i);
                if (mkdir(tmpdir,0755) == 0)
                        break;
                if (errno == EEXIST)
index 5bf93de9f473f9a995b993922dd4490af0247ed2..5ca1c45bfb71c884ab4c44f14cf30fd74e51586b 100644 (file)
@@ -908,6 +908,7 @@ int main(int argc, char **argv)
        char *testprg;
 #endif
        const char *opt_arg, *progname, *p;
+       char *tmp;
        char tmpdir[256];
        char tmpdir_timestamp[256];
 
@@ -930,6 +931,17 @@ int main(int argc, char **argv)
        testprog = getenv(ENVBASE);
 #endif
 
+       if (getenv("TMPDIR") != NULL)
+               tmp = getenv("TMPDIR");
+       else if (getenv("TMP") != NULL)
+               tmp = getenv("TMP");
+       else if (getenv("TEMP") != NULL)
+               tmp = getenv("TEMP");
+       else if (getenv("TEMPDIR") != NULL)
+               tmp = getenv("TEMPDIR");
+       else
+               tmp = "/tmp";
+
        /* Allow -d to be controlled through the environment. */
        if (getenv(ENVBASE "_DEBUG") != NULL)
                dump_on_failure = 1;
@@ -1025,7 +1037,8 @@ int main(int argc, char **argv)
                strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp),
                    "%Y-%m-%dT%H.%M.%S",
                    localtime(&now));
-               sprintf(tmpdir, "/tmp/%s.%s-%03d", progname, tmpdir_timestamp, i);
+               sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname,
+                   tmpdir_timestamp, i);
                if (mkdir(tmpdir,0755) == 0)
                        break;
                if (errno == EEXIST)