summaryrefslogtreecommitdiff
path: root/pgsql.c
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2012-04-12 20:11:06 +0200
committerAndreas Baumann <abaumann@yahoo.com>2012-04-12 20:11:06 +0200
commit10c8b7ed06f223697dea3293706daff56be2da8e (patch)
treeb3636ed3757216f298c2c3b52bf09098f9cef8dc /pgsql.c
parentd4b001331944baae47ae7ed1fd389601cff3a16e (diff)
downloadpgfuse-10c8b7ed06f223697dea3293706daff56be2da8e.tar.gz
pgfuse-10c8b7ed06f223697dea3293706daff56be2da8e.tar.bz2
implemented rmdir
Diffstat (limited to 'pgsql.c')
-rw-r--r--pgsql.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/pgsql.c b/pgsql.c
index 9b7e53b..29fea0b 100644
--- a/pgsql.c
+++ b/pgsql.c
@@ -185,6 +185,28 @@ int psql_create_dir( PGconn *conn, const int parent_id, const char *path, const
return 0;
}
+int psql_delete_dir( PGconn *conn, const int id, const char *path )
+{
+ int param1 = htonl( id );
+ const char *values[1] = { (char *)&param1 };
+ int lengths[1] = { sizeof( param1 ) };
+ int binary[1] = { 1 };
+ PGresult *res;
+
+ res = PQexecParams( conn, "DELETE FROM dir where id=$1::int4",
+ 1, NULL, values, lengths, binary, 1 );
+
+ if( PQresultStatus( res ) != PGRES_COMMAND_OK ) {
+ syslog( LOG_ERR, "Error in psql_delete_dir for path '%s': %s", path, PQerrorMessage( conn ) );
+ PQclear( res );
+ return -EIO;
+ }
+
+ PQclear( res );
+
+ return 0;
+}
+
int psql_write_buf( PGconn *conn, const int id, const char *path, const char *buf, const size_t len )
{
int param1 = htonl( id );