core: Switch to using mkdtemp() so we only depend on GLib 2.28
We claim to build against 2.28, let's actually make it work.
This commit is contained in:
1 parent
f438d9aaa6
commit
cbd4ade053
4 files changed
+58
-14
No files matched your search
@@ -20,12 +20,17 @@
|
||||
* Author: Colin Walters <walters@verbum.org>
|
||||
*/
|
||||
|
||||
/* for mkdtemp */
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "ostree.h"
|
||||
#include "otutil.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <attr/xattr.h>
|
||||
|
||||
#define ALIGN_VALUE(this, boundary) \
|
||||
@@ -1303,6 +1308,40 @@ ostree_create_temp_regular_file (GFile *dir,
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_create_temp_dir (GFile *dir,
|
||||
const char *prefix,
|
||||
const char *suffix,
|
||||
GFile **out_file,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
ot_lfree char *template = NULL;
|
||||
ot_lobj GFile *ret_file = NULL;
|
||||
|
||||
if (dir == NULL)
|
||||
dir = g_file_new_for_path (g_get_tmp_dir ());
|
||||
|
||||
template = g_strdup_printf ("%s/%s-XXXXXX-%s",
|
||||
ot_gfile_get_path_cached (dir),
|
||||
prefix ? prefix : "tmp",
|
||||
suffix ? suffix : "tmp");
|
||||
|
||||
if (mkdtemp (template) == NULL)
|
||||
{
|
||||
ot_util_set_error_from_errno (error, errno);
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret_file = g_file_new_for_path (template);
|
||||
|
||||
ret = TRUE;
|
||||
ot_transfer_out_value (out_file, &ret_file);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
gboolean
|
||||
ostree_read_pack_entry_raw (guchar *pack_data,
|
||||
guint64 pack_len,
|
||||
|
||||
@@ -297,6 +297,13 @@ gboolean ostree_create_temp_regular_file (GFile *dir,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_create_temp_dir (GFile *dir,
|
||||
const char *prefix,
|
||||
const char *suffix,
|
||||
GFile **out_file,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
|
||||
gboolean ostree_read_pack_entry_raw (guchar *pack_data,
|
||||
guint64 pack_len,
|
||||
guint64 object_offset,
|
||||
|
||||
Reference in new issue
Block a user