mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-26 23:25:56 -05:00
[db] Fetch directory id by path; use const for path and virtual_path
This commit is contained in:
parent
dc020cc3ac
commit
070379edef
26
src/db.c
26
src/db.c
@ -3850,7 +3850,7 @@ db_group_persistentid_byid(int id, int64_t *persistentid)
|
||||
|
||||
/* Directories */
|
||||
int
|
||||
db_directory_id_byvirtualpath(char *virtual_path)
|
||||
db_directory_id_byvirtualpath(const char *virtual_path)
|
||||
{
|
||||
#define Q_TMPL "SELECT d.id FROM directories d WHERE d.virtual_path = '%q';"
|
||||
char *query;
|
||||
@ -3873,6 +3873,30 @@ db_directory_id_byvirtualpath(char *virtual_path)
|
||||
#undef Q_TMPL
|
||||
}
|
||||
|
||||
int
|
||||
db_directory_id_bypath(const char *path)
|
||||
{
|
||||
#define Q_TMPL "SELECT d.id FROM directories d WHERE d.path = '%q';"
|
||||
char *query;
|
||||
int ret;
|
||||
|
||||
query = sqlite3_mprintf(Q_TMPL, path);
|
||||
if (!query)
|
||||
{
|
||||
DPRINTF(E_LOG, L_DB, "Out of memory for query string\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = db_file_id_byquery(query);
|
||||
|
||||
sqlite3_free(query);
|
||||
|
||||
return ret;
|
||||
|
||||
#undef Q_TMPL
|
||||
}
|
||||
|
||||
int
|
||||
db_directory_enum_start(struct directory_enum *de)
|
||||
{
|
||||
|
5
src/db.h
5
src/db.h
@ -699,7 +699,10 @@ db_group_persistentid_byid(int id, int64_t *persistentid);
|
||||
|
||||
/* Directories */
|
||||
int
|
||||
db_directory_id_byvirtualpath(char *virtual_path);
|
||||
db_directory_id_byvirtualpath(const char *virtual_path);
|
||||
|
||||
int
|
||||
db_directory_id_bypath(const char *path);
|
||||
|
||||
int
|
||||
db_directory_enum_start(struct directory_enum *de);
|
||||
|
Loading…
Reference in New Issue
Block a user