summaryrefslogtreecommitdiff
path: root/glnx-dirfd.h
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2017-08-18 14:45:07 -0400
committerColin Walters <walters@verbum.org>2017-08-18 16:01:38 -0400
commit7100ebbc6800c7e5e2e09cefe067fbb88b32f10b (patch)
tree3cfd09124ed0a54287c09530eaa4bc07d1116126 /glnx-dirfd.h
parente226ccf6913d1d852fde1e150a99fab508f85c34 (diff)
downloadlibglnx-7100ebbc6800c7e5e2e09cefe067fbb88b32f10b.tar.gz
dirfd: New tmpdir API
Basically all of the ostree/rpm-ostree callers want to both create and open, so let's merge `glnx_mkdtempat()` and `glnx_mkdtempat_open()`. Second, all of them want to do `glnx_shutil_rm_rf_at()` on cleanup, so we do the same thing we did with `GLnxTmpfile` and create `GLnxTmpDir` that has a cleanup attribute. The cleanup this results in for rpm-ostree is pretty substantial.
Diffstat (limited to 'glnx-dirfd.h')
-rw-r--r--glnx-dirfd.h25
1 files changed, 12 insertions, 13 deletions
diff --git a/glnx-dirfd.h b/glnx-dirfd.h
index 8e582fc..5e362fa 100644
--- a/glnx-dirfd.h
+++ b/glnx-dirfd.h
@@ -113,20 +113,19 @@ glnx_ensure_dir (int dfd,
return TRUE;
}
-gboolean glnx_mkdtempat (int dfd,
- gchar *tmpl,
- int mode,
- GError **error);
+typedef struct {
+ gboolean initialized;
+ int src_dfd;
+ int fd;
+ char *path;
+} GLnxTmpDir;
+void glnx_tmpdir_clear (GLnxTmpDir *tmpf);
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxTmpDir, glnx_tmpdir_clear)
-gboolean glnx_mkdtempat_open (int dfd,
- gchar *tmpl,
- int mode,
- int *out_dfd,
- GError **error);
+gboolean glnx_mkdtempat (int dfd, const char *tmpl, int mode,
+ GLnxTmpDir *out_tmpdir, GError **error);
-gboolean glnx_mkdtempat_open_in_system (gchar *tmpl,
- int mode,
- int *out_dfd,
- GError **error);
+gboolean glnx_mkdtemp (const char *tmpl, int mode,
+ GLnxTmpDir *out_tmpdir, GError **error);
G_END_DECLS