changeset 1802:8173b1fa052d

[project @ 1996-01-29 06:10:18 by jwe]
author jwe
date Mon, 29 Jan 1996 06:18:29 +0000
parents 401f4226c639
children 3a16afafc2ee
files liboctave/file-ops.cc src/file-io.cc src/oct-hist.cc src/pt-plot.cc src/utils.cc
diffstat 5 files changed, 42 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/file-ops.cc	Mon Jan 29 06:03:49 1996 +0000
+++ b/liboctave/file-ops.cc	Mon Jan 29 06:18:29 1996 +0000
@@ -26,6 +26,8 @@
 #endif
 
 #include <cerrno>
+#include <cstdio>
+#include <cstdlib>
 #include <cstring>
 
 #ifdef HAVE_UNISTD_H
@@ -34,6 +36,7 @@
 #endif
 
 #include "file-ops.h"
+#include "lo-error.h"
 #include "statdefs.h"
 
 // These must come after <sys/types.h> and <sys/stat.h>.
@@ -221,6 +224,26 @@
   return rmdir (name.c_str ());
 }
 
+string
+oct_tempnam (void)
+{
+  string retval;
+
+  char *tmp = tempnam (0, "oct-");
+
+  if (tmp)
+    {
+      retval = tmp;
+
+      free (tmp);
+    }
+  else
+    (*current_liboctave_error_handler) ("can't open temporary file!");
+
+  return retval;
+}
+
+
 int
 oct_umask (mode_t mode)
 {
--- a/src/file-io.cc	Mon Jan 29 06:03:49 1996 +0000
+++ b/src/file-io.cc	Mon Jan 29 06:18:29 1996 +0000
@@ -1384,7 +1384,7 @@
 	  xstring = xstring_str.c_str ();
 	}
 
-      tmp_file = octave_tmp_file_name ();
+      tmp_file = oct_tempnam ();
 
       fptr = fopen (tmp_file.c_str (), "w+");
       if (! fptr)
@@ -2513,6 +2513,20 @@
   return retval;
 }
 
+DEFUN ("octave_tmp_file_name", Foctave_tmp_file_name,
+       Soctave_tmp_file_name, 10,
+ "octave_tmp_file_name ()")
+{
+  tree_constant retval;
+
+  if (args.length () == 0)
+    retval = oct_tempnam ();
+  else
+    print_usage ("octave_tmp_file_name");
+
+  return retval;
+}
+
 static int
 convert (int x, int ibase, int obase)
 {
--- a/src/oct-hist.cc	Mon Jan 29 06:03:49 1996 +0000
+++ b/src/oct-hist.cc	Mon Jan 29 06:18:29 1996 +0000
@@ -47,6 +47,7 @@
 #endif
 
 #include "cmd-hist.h"
+#include "file-ops.h"
 #include "str-vec.h"
 
 #include "defun.h"
@@ -387,7 +388,7 @@
       reverse = 1;
     }
 
-  string name = octave_tmp_file_name ();
+  string name = oct_tempnam ();
 
   fstream file (name.c_str (), ios::out);
 
--- a/src/pt-plot.cc	Mon Jan 29 06:03:49 1996 +0000
+++ b/src/pt-plot.cc	Mon Jan 29 06:18:29 1996 +0000
@@ -45,6 +45,7 @@
 #include "SLStack.h"
 #include "procstream.h"
 
+#include "file-ops.h"
 #include "str-vec.h"
 
 #include "defun.h"
@@ -914,7 +915,7 @@
 string
 save_in_tmp_file (tree_constant& t, int ndim, int parametric)
 {
-  string name = octave_tmp_file_name ();
+  string name = oct_tempnam ();
 
   if (! name.empty ())
     {
--- a/src/utils.cc	Mon Jan 29 06:03:49 1996 +0000
+++ b/src/utils.cc	Mon Jan 29 06:18:29 1996 +0000
@@ -166,41 +166,6 @@
 }
 #endif
 
-// Get a temporary file name.
-
-string
-octave_tmp_file_name (void)
-{
-  string retval;
-
-  char *tmp = tempnam (0, "oct-");
-
-  if (tmp)
-    {
-      retval = tmp;
-
-      free (tmp);
-    }
-  else
-    error ("can't open temporary file!");
-
-  return retval;
-}
-
-DEFUN ("octave_tmp_file_name", Foctave_tmp_file_name,
-       Soctave_tmp_file_name, 10,
- "octave_tmp_file_name ()")
-{
-  tree_constant retval;
-
-  if (args.length () == 0)
-    retval = octave_tmp_file_name ();
-  else
-    print_usage ("octave_tmp_file_name");
-
-  return retval;
-}
-
 // Return to the main command loop in octave.cc.
 
 extern "C" void