X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fclean-temp.h;h=65c427c384e35d75704fbfdab161ebf567f30612;hb=fa3486514bd8f15f8eb4c49821d0356b52e5a335;hp=c564addacc86587a8280a8866be8619e19c756e5;hpb=0a62266097226ade8e0bdcda3d733542144baaeb;p=gnulib.git diff --git a/lib/clean-temp.h b/lib/clean-temp.h index c564addac..65c427c38 100644 --- a/lib/clean-temp.h +++ b/lib/clean-temp.h @@ -2,10 +2,10 @@ Copyright (C) 2006 Free Software Foundation, Inc. Written by Bruno Haible , 2006. - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,13 +13,14 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ #ifndef _CLEAN_TEMP_H #define _CLEAN_TEMP_H #include +#include +#include #ifdef __cplusplus extern "C" { @@ -32,6 +33,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) can one 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. */ @@ -83,20 +88,42 @@ extern void register_temp_subdir (struct temp_dir *dir, extern void unregister_temp_subdir (struct temp_dir *dir, const char *absolute_dir_name); -/* Remove the given ABSOLUTE_FILE_NAME and unregister it. */ -extern void cleanup_temp_file (struct temp_dir *dir, - const char *absolute_file_name); +/* Remove the given ABSOLUTE_FILE_NAME and unregister it. + Return 0 upon success, or -1 if there was some problem. */ +extern int cleanup_temp_file (struct temp_dir *dir, + const char *absolute_file_name); -/* Remove the given ABSOLUTE_DIR_NAME and unregister it. */ -extern void cleanup_temp_subdir (struct temp_dir *dir, - const char *absolute_dir_name); +/* Remove the given ABSOLUTE_DIR_NAME and unregister it. + Return 0 upon success, or -1 if there was some problem. */ +extern int cleanup_temp_subdir (struct temp_dir *dir, + const char *absolute_dir_name); -/* Remove all registered files and subdirectories inside DIR. */ -extern void cleanup_temp_dir_contents (struct temp_dir *dir); +/* Remove all registered files and subdirectories inside DIR. + Return 0 upon success, or -1 if there was some problem. */ +extern int cleanup_temp_dir_contents (struct temp_dir *dir); /* Remove all registered files and subdirectories inside DIR and DIR itself. - DIR cannot be used any more after this call. */ -extern void cleanup_temp_dir (struct temp_dir *dir); + DIR cannot be used any more after this call. + Return 0 upon success, or -1 if there was some problem. */ +extern int 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); + +/* Like close_stream. + Unregisters the previously registered file descriptor. */ +extern int close_stream_temp (FILE *fp); #ifdef __cplusplus