[libgsystem] fileutil: Make API to generate temporary name public
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsystem] fileutil: Make API to generate temporary name public
- Date: Tue, 16 Jul 2013 12:51:40 +0000 (UTC)
commit 4a41cb7911ac97eeac297a3177375b8198a433d2
Author: Colin Walters <walters verbum org>
Date: Tue Jul 16 08:45:46 2013 -0400
fileutil: Make API to generate temporary name public
It's used by ostree core too.
gsystem-file-utils.c | 17 +++++++++++++----
gsystem-file-utils.h | 3 +++
2 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/gsystem-file-utils.c b/gsystem-file-utils.c
index 2f57efa..69a2caf 100644
--- a/gsystem-file-utils.c
+++ b/gsystem-file-utils.c
@@ -312,9 +312,18 @@ get_default_tmp_prefix (void)
return tmpprefix;
}
-static char *
-gen_tmp_name (const char *prefix,
- const char *suffix)
+/**
+ * gsystem_fileutil_gen_tmp_name:
+ * @prefix: (allow-none): String prepended to the result
+ * @suffix: (allow-none): String suffixed to the result
+ *
+ * Generate a name suitable for use as a temporary file. This
+ * function does no I/O; it is not guaranteed that a file with that
+ * name does not exist.
+ */
+char *
+gsystem_fileutil_gen_tmp_name (const char *prefix,
+ const char *suffix)
{
static const char table[] = "ABCEDEFGHIJKLMNOPQRSTUVWXYZabcedefghijklmnopqrstuvwxyz0123456789";
GString *str = g_string_new ("");
@@ -356,7 +365,7 @@ linkcopy_internal_attempt (GFile *src,
if (g_cancellable_set_error_if_cancelled (cancellable, error))
goto out;
- tmp_name = gen_tmp_name (NULL, NULL);
+ tmp_name = gsystem_fileutil_gen_tmp_name (NULL, NULL);
tmp_dest = g_file_get_child (dest_parent, tmp_name);
res = link (gs_file_get_path_cached (src), gs_file_get_path_cached (tmp_dest));
diff --git a/gsystem-file-utils.h b/gsystem-file-utils.h
index b553d7f..26ee878 100644
--- a/gsystem-file-utils.h
+++ b/gsystem-file-utils.h
@@ -52,6 +52,9 @@ gboolean gs_file_sync_data (GFile *file,
GCancellable *cancellable,
GError **error);
+char * gsystem_fileutil_gen_tmp_name (const char *prefix,
+ const char *suffix);
+
gboolean gs_file_create (GFile *file,
int mode,
GOutputStream **out_stream,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]