Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tempfile.c8
-rw-r--r--tempfile.h8
2 files changed, 16 insertions, 0 deletions
diff --git a/tempfile.c b/tempfile.c
index 0b5d8ce929..0af7ebf016 100644
--- a/tempfile.c
+++ b/tempfile.c
@@ -137,6 +137,14 @@ int create_tempfile(struct tempfile *tempfile, const char *path)
return tempfile->fd;
}
+void register_tempfile(struct tempfile *tempfile, const char *path)
+{
+ prepare_tempfile_object(tempfile);
+ strbuf_add_absolute_path(&tempfile->filename, path);
+ tempfile->owner = getpid();
+ tempfile->active = 1;
+}
+
int mks_tempfile_sm(struct tempfile *tempfile,
const char *template, int suffixlen, int mode)
{
diff --git a/tempfile.h b/tempfile.h
index a30e12c7e5..4219fe41bd 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