[GRASS-SVN] r53605 - grass/trunk/db/drivers/sqlite

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 29 07:56:17 PDT 2012


Author: martinl
Date: 2012-10-29 07:56:17 -0700 (Mon, 29 Oct 2012)
New Revision: 53605

Modified:
   grass/trunk/db/drivers/sqlite/db.c
Log:
SQLite DB driver: implement delete_database()


Modified: grass/trunk/db/drivers/sqlite/db.c
===================================================================
--- grass/trunk/db/drivers/sqlite/db.c	2012-10-29 09:43:06 UTC (rev 53604)
+++ grass/trunk/db/drivers/sqlite/db.c	2012-10-29 14:56:17 UTC (rev 53605)
@@ -102,7 +102,6 @@
  *
  * \return always returns DB_OK
  */
-
 int db__driver_close_database(void)
 {
     G_debug(3, "db_close_database()");
@@ -117,11 +116,10 @@
  * \brief Create new empty SQLite database.
  *
  * \param handle dbHandle
-
+ *
  * \return DB_OK on success
  * \return DB_FAILED on failure
  */
-
 int db__driver_create_database(dbHandle *handle)
 {
     const char *name;
@@ -144,5 +142,27 @@
 	return DB_FAILED;
     }
     
-    return DB_FAILED;
+    return DB_OK;
 }
+
+/**
+ * \brief Delete existing SQLite database.
+ *
+ * \param handle dbHandle
+ *
+ * \return DB_OK on success
+ * \return DB_FAILED on failure
+ */
+int db__driver_delete_database(dbHandle *handle)
+{
+    const char *name;
+    name = db_get_handle_dbname(handle);
+    
+    if (access(name, F_OK) != 0) {
+        db_d_append_error(_("Database <%s> not found"), name);
+        db_d_report_error();
+        return DB_FAILED;
+    }
+
+    return remove(name) == 0 ? DB_OK : DB_FAILED;
+}



More information about the grass-commit mailing list