コード例 #1
0
ファイル: gvdb-builder.c プロジェクト: MekaClaude/flatpak
GBytes *
gvdb_table_get_content (GHashTable     *table,
                        gboolean        byteswap)
{
  struct gvdb_pointer root;
  FileBuilder *fb;
  GString *str;
  GBytes *res;

  fb = file_builder_new (byteswap);
  file_builder_add_hash (fb, table, &root);
  str = file_builder_serialise (fb, root);

  res = g_bytes_new_take (str->str, str->len);
  g_string_free (str, FALSE);

  return res;
}
コード例 #2
0
gboolean
gvdb_table_write_contents (GHashTable   *table,
                           const gchar  *filename,
                           gboolean      byteswap,
                           GError      **error)
{
  struct gvdb_pointer root;
  gboolean status;
  FileBuilder *fb;
  GString *str;

  fb = file_builder_new (byteswap);
  file_builder_add_hash (fb, table, &root);
  str = file_builder_serialise (fb, root);

  status = g_file_set_contents (filename, str->str, str->len, error);
  g_string_free (str, TRUE);

  return status;
}