diff options
author | Colin Walters <walters@verbum.org> | 2017-08-18 14:45:07 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2017-08-18 16:01:38 -0400 |
commit | 7100ebbc6800c7e5e2e09cefe067fbb88b32f10b (patch) | |
tree | 3cfd09124ed0a54287c09530eaa4bc07d1116126 /glnx-dirfd.h | |
parent | e226ccf6913d1d852fde1e150a99fab508f85c34 (diff) | |
download | libglnx-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.h | 25 |
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 |