summaryrefslogtreecommitdiff
path: root/db.c
diff options
context:
space:
mode:
Diffstat (limited to 'db.c')
-rw-r--r--db.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/db.c b/db.c
index 2fbaed8..931767d 100644
--- a/db.c
+++ b/db.c
@@ -271,6 +271,33 @@ sqlite_uint64 db_add_wallpaper(const char *filepath, sqlite_uint64 dirid, int si
}
}
+sqlite_uint64 db_get_wallpaper(const char *path) {
+ sqlite3_stmt *stmt;
+ int rc;
+ sqlite_uint64 dirid;
+
+ rc = sqlite3_prepare_v2(db, "SELECT id FROM wallpaper WHERE filepath = ? LIMIT 1", -1, &stmt, NULL);
+ if(rc != SQLITE_OK) {
+ return 0;
+ }
+
+ rc = sqlite3_bind_text(stmt, 1, path, -1, SQLITE_STATIC);
+ if(rc != SQLITE_OK) {
+ sqlite3_finalize(stmt);
+ return 0;
+ }
+
+ rc = sqlite3_step(stmt);
+ if(rc == SQLITE_ROW) {
+ dirid = sqlite3_column_int64(stmt, 0);
+ sqlite3_finalize(stmt);
+ return dirid;
+ }
+
+ sqlite3_finalize(stmt);
+ return 0;
+}
+
int db_get_wallpapers(sqlite_uint64 dirid, GArray **array) {
struct wallpaper_t temp, *temp2;
sqlite3_stmt *stmt;