X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fcasefile.c;h=97929c570eaaa81b655cba62f6a2c32dacdfacd7;hb=4848cff524922cc77ed21662406807471e96a68e;hp=242fc385c0ca7890e3017d3c239fdf72ebad6f08;hpb=8bc8a011fa9df5b9f5aa00144c8d3478fd7b93fa;p=pspp diff --git a/src/casefile.c b/src/casefile.c index 242fc385c0..97929c570e 100644 --- a/src/casefile.c +++ b/src/casefile.c @@ -30,9 +30,9 @@ #include "case.h" #include "error.h" #include "misc.h" +#include "mkfile.h" #include "settings.h" #include "var.h" -#include "signal.h" #ifdef HAVE_VALGRIND_VALGRIND_H #include @@ -340,35 +340,6 @@ flush_buffer (struct casefile *cf) } } -/* Creates a temporary file and stores its name in *FILENAME and - a file descriptor for it in *FD. Returns success. Caller is - responsible for freeing *FILENAME. */ -static int -make_temp_file (int *fd, char **filename) -{ - const char *parent_dir; - - assert (filename != NULL); - assert (fd != NULL); - - if (getenv ("TMPDIR") != NULL) - parent_dir = getenv ("TMPDIR"); - else - parent_dir = P_tmpdir; - - *filename = xmalloc (strlen (parent_dir) + 32); - sprintf (*filename, "%s%cpsppXXXXXX", parent_dir, DIR_SEPARATOR); - *fd = mkstemp (*filename); - if (*fd < 0) - { - msg (FE, _("%s: Creating temporary file: %s."), - *filename, strerror (errno)); - free (*filename); - *filename = NULL; - return 0; - } - return 1; -} /* If CF is currently stored in memory, writes it to disk. Readers, if any, retain their current positions. */ @@ -727,6 +698,7 @@ full_write (int fd, const void *buffer_, size_t size) return bytes_written; } + /* Registers our exit handler with atexit() if it has not already been registered. */ static void @@ -736,12 +708,12 @@ register_atexit (void) if (!registered) { registered = 1; - signal (SIGQUIT, (sighandler_t) exit_handler); - signal (SIGINT, (sighandler_t) exit_handler); atexit (exit_handler); } } + + /* atexit() handler that closes and deletes our temporary files. */ static void