summaryrefslogtreecommitdiff
path: root/lib/clean-temp.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2006-10-06 12:17:22 +0000
committerBruno Haible <bruno@clisp.org>2006-10-06 12:17:22 +0000
commitbd63935b8ac05a50706b7b56540cd0396b528c77 (patch)
tree1f888e70a34ae06140aa705ef6b224e99a9a0580 /lib/clean-temp.h
parentfca2f939ea0d8831cd89f89df4b52a9a47c210f2 (diff)
downloadgnulib-bd63935b8ac05a50706b7b56540cd0396b528c77.tar.gz
Have clean-temp register file open descriptors to temporary files.
Diffstat (limited to 'lib/clean-temp.h')
-rw-r--r--lib/clean-temp.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/clean-temp.h b/lib/clean-temp.h
index c564addacc..aa5e8d3d59 100644
--- a/lib/clean-temp.h
+++ b/lib/clean-temp.h
@@ -20,6 +20,8 @@
#define _CLEAN_TEMP_H
#include <stdbool.h>
+#include <stdio.h>
+#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
@@ -32,6 +34,10 @@ extern "C" {
also - if no signal blocking is used - leaves a time window where a fatal
signal would not clean up the temporary file.
+ Also, open file descriptors need to be closed before the temporary files
+ and the temporary directories can be removed, because only on Unix
+ (excluding Cygwin) one can remove directories containing open files.
+
This module provides support for temporary directories and temporary files
inside these temporary directories. Temporary files without temporary
directories are not supported here. */
@@ -98,6 +104,20 @@ extern void cleanup_temp_dir_contents (struct temp_dir *dir);
DIR cannot be used any more after this call. */
extern void cleanup_temp_dir (struct temp_dir *dir);
+/* Open a temporary file in a temporary directory.
+ Registers the resulting file descriptor to be closed. */
+extern int open_temp (const char *file_name, int flags, mode_t mode);
+extern FILE * fopen_temp (const char *file_name, const char *mode);
+
+/* Close a temporary file in a temporary directory.
+ Unregisters the previously registered file descriptor. */
+extern int close_temp (int fd);
+extern int fclose_temp (FILE *fp);
+
+/* Like fwriteerror.
+ Unregisters the previously registered file descriptor. */
+extern int fwriteerror_temp (FILE *fp);
+
#ifdef __cplusplus
}