[Groonga-commit] groonga/groonga-gobject at b50f4f0 [master] Add ggrn_context_create_database()

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Dec 2 23:14:32 JST 2013


Kouhei Sutou	2013-12-02 23:14:32 +0900 (Mon, 02 Dec 2013)

  New Revision: b50f4f04571fc72541bdd598687322950944ff6d
  https://github.com/groonga/groonga-gobject/commit/b50f4f04571fc72541bdd598687322950944ff6d

  Message:
    Add ggrn_context_create_database()

  Modified files:
    groonga-gobject/ggrn-context.c
    groonga-gobject/ggrn-context.h

  Modified: groonga-gobject/ggrn-context.c (+27 -0)
===================================================================
--- groonga-gobject/ggrn-context.c    2013-12-02 23:10:03 +0900 (32155d5)
+++ groonga-gobject/ggrn-context.c    2013-12-02 23:14:32 +0900 (ab32247)
@@ -133,6 +133,33 @@ ggrn_context_open_database(GGrnContext *context,
 }
 
 /**
+ * ggrn_context_create_database:
+ * @context: A #GGrnContext.
+ * @path: (allow-none): The path of the database to be created, or %NULL
+ *   for temporary database.
+ * @error: return location for a GError, or %NULL.
+ *
+ * Creates a new database.
+ *
+ * Returns: TRUE on success, FALSE if an error occurred.
+ */
+gboolean
+ggrn_context_create_database(GGrnContext *context,
+                             const gchar *path, GError **error)
+{
+    GGrnContextPrivate *priv = GGRN_CONTEXT_GET_PRIVATE(context);
+    grn_obj *using_database;
+
+    using_database = grn_ctx_db(priv->ctx);
+    if (using_database) {
+        grn_db_close(priv->ctx, using_database);
+    }
+
+    grn_db_create(priv->ctx, path, NULL);
+    return _ggrn_rc_check(priv->ctx->rc, error);
+}
+
+/**
  * ggrn_context_execute_command:
  * @context: A #GGrnContext.
  * @command:

  Modified: groonga-gobject/ggrn-context.h (+3 -0)
===================================================================
--- groonga-gobject/ggrn-context.h    2013-12-02 23:10:03 +0900 (b1df75f)
+++ groonga-gobject/ggrn-context.h    2013-12-02 23:14:32 +0900 (b279906)
@@ -60,6 +60,9 @@ GGrnContext         *ggrn_context_new               (void);
 gboolean             ggrn_context_open_database     (GGrnContext  *context,
                                                      const gchar  *path,
                                                      GError      **error);
+gboolean             ggrn_context_create_database   (GGrnContext  *context,
+                                                     const gchar  *path,
+                                                     GError      **error);
 void                 ggrn_context_execute_command   (GGrnContext  *context,
                                                      const gchar  *command,
                                                      gchar       **result);
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index