bug-enscript
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-enscript] enscript and temp file location


From: Giulio Orsero
Subject: Re: [bug-enscript] enscript and temp file location
Date: Fri, 14 Nov 2008 15:39:22 +0100

On Thu, Nov 13, 2008 at 2:19 PM, Tapani Tarvainen <address@hidden> wrote:
On Thu, Nov 13, 2008 at 01:55:45PM +0100, Giulio Orsero (address@hidden) wrote:

> >     divertftp = fdopen(fd,"w+b");
> I need to add something to get the temp file deleted after its use.
Yeah. I guess the easiest way is to do
     unlink(filename);
just after opening it - then it will disappear when it's closed.

I added the unlink() and postponed the free() if "fd" is not "-1".
It seems to work.
Thanks.

===============
@@ -2812,12 +2813,27 @@
   assert (divertfp == NULL);
 
   /* Open divert file. */
-
+#if 0
   divertfp = tmpfile ();
+#endif
+  char *filename;
+  int fd;
+
+  do {
+    filename = tempnam (NULL, "enscript");
+    fd = open (filename, O_CREAT | O_EXCL | O_TRUNC | O_RDWR, 0600);
+    if (fd == -1) free (filename);
+  } while (fd == -1);
+
+  divertfp = fdopen(fd,"w+b");
+
    if (divertfp == NULL)
     FATAL ((stderr, _("couldn't create temporary divert file: %s"),
        strerror (errno)));
 
+  unlink(filename);
+  free(filename);
+
==============

--
address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]