summaryrefslogtreecommitdiff
path: root/tempfile.h
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-08-10 09:47:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-08-10 19:57:14 (GMT)
commit99397152a345011c99497b93f8518c7981e811a5 (patch)
tree94413563c2fcdfa2ccbcfd38ca29a3e4e3a2620d /tempfile.h
parent354ab1120665f691c17b21fdb04c4362c8088dfa (diff)
downloadgit-99397152a345011c99497b93f8518c7981e811a5.zip
git-99397152a345011c99497b93f8518c7981e811a5.tar.gz
git-99397152a345011c99497b93f8518c7981e811a5.tar.bz2
register_tempfile(): new function to handle an existing temporary file
Allow an existing file to be registered with the tempfile-handling infrastructure; in particular, arrange for it to be deleted on program exit. This can be used if the temporary file has to be created in a more complicated way than just open(). For example: * If the file itself needs to be created via the lockfile API * If it is not a regular file (e.g., a socket) Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'tempfile.h')
-rw-r--r--tempfile.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/tempfile.h b/tempfile.h
index a30e12c..4219fe4 100644
--- a/tempfile.h
+++ b/tempfile.h
@@ -92,6 +92,14 @@ struct tempfile {
*/
extern int create_tempfile(struct tempfile *tempfile, const char *path);
+/*
+ * Register an existing file as a tempfile, meaning that it will be
+ * deleted when the program exits. The tempfile is considered closed,
+ * but it can be worked with like any other closed tempfile (for
+ * example, it can be opened using reopen_tempfile()).
+ */
+extern void register_tempfile(struct tempfile *tempfile, const char *path);
+
/*
* mks_tempfile functions