diff src/editfns.c @ 263:727739f917cb r20-5b30

Import from CVS: tag r20-5b30
author cvs
date Mon, 13 Aug 2007 10:24:41 +0200
parents 65c19d2020f7
children c5d627a313b1
line wrap: on
line diff
--- a/src/editfns.c	Mon Aug 13 10:23:52 2007 +0200
+++ b/src/editfns.c	Mon Aug 13 10:24:41 2007 +0200
@@ -609,6 +609,31 @@
 }
 
 
+DEFUN ("temp-directory", Ftemp_directory, 0, 0, 0, /*
+Return the pathname to the directory to use for temporary files.
+On NT/MSDOS, this is obtained from the TEMP or TMP environment variables,
+defaulting to / if they are both undefined.
+On Unix it is obtained from TMPDIR, with /tmp as the default
+*/
+       ())
+{
+  char *tmpdir;
+
+#if defined(WINDOWSNT) || defined(MSDOS)
+  tmpdir = (char *) getenv ("TEMP");
+  if (!tmpdir)
+    tmpdir = (char *) getenv ("TMP");
+  if (!tmpdir)
+    tmpdir = "/";	/* what should this be on NT/MSDOS ? */
+#else /* WINDOWSNT || MSDOS */
+  tmpdir = (char *) getenv ("TMPDIR");
+  if (!tmpdir)
+    tmpdir = "/tmp";
+#endif
+
+  return build_ext_string (tmpdir, FORMAT_FILENAME);
+}
+
 DEFUN ("user-login-name", Fuser_login_name, 0, 1, 0, /*
 Return the name under which the user logged in, as a string.
 This is based on the effective uid, not the real uid.
@@ -2137,6 +2162,7 @@
   DEFSUBR (Finsert_before_markers);
   DEFSUBR (Finsert_char);
 
+  DEFSUBR (Ftemp_directory);
   DEFSUBR (Fuser_login_name);
   DEFSUBR (Fuser_real_login_name);
   DEFSUBR (Fuser_uid);