playlist_vector: update_or_add() returns bool
False if the vector was not modified.
This commit is contained in:
parent
bc87ec0059
commit
663815ead8
@ -93,16 +93,21 @@ playlist_vector_add(struct playlist_vector *pv,
|
|||||||
pv->head = pm;
|
pv->head = pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
playlist_vector_update_or_add(struct playlist_vector *pv,
|
playlist_vector_update_or_add(struct playlist_vector *pv,
|
||||||
const char *name, time_t mtime)
|
const char *name, time_t mtime)
|
||||||
{
|
{
|
||||||
struct playlist_metadata **pmp = playlist_vector_find_p(pv, name);
|
struct playlist_metadata **pmp = playlist_vector_find_p(pv, name);
|
||||||
if (pmp != NULL) {
|
if (pmp != NULL) {
|
||||||
struct playlist_metadata *pm = *pmp;
|
struct playlist_metadata *pm = *pmp;
|
||||||
|
if (mtime == pm->mtime)
|
||||||
|
return false;
|
||||||
|
|
||||||
pm->mtime = mtime;
|
pm->mtime = mtime;
|
||||||
} else
|
} else
|
||||||
playlist_vector_add(pv, name, mtime);
|
playlist_vector_add(pv, name, mtime);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -58,7 +58,10 @@ void
|
|||||||
playlist_vector_add(struct playlist_vector *pv,
|
playlist_vector_add(struct playlist_vector *pv,
|
||||||
const char *name, time_t mtime);
|
const char *name, time_t mtime);
|
||||||
|
|
||||||
void
|
/**
|
||||||
|
* @return true if the vector or one of its items was modified
|
||||||
|
*/
|
||||||
|
bool
|
||||||
playlist_vector_update_or_add(struct playlist_vector *pv,
|
playlist_vector_update_or_add(struct playlist_vector *pv,
|
||||||
const char *name, time_t mtime);
|
const char *name, time_t mtime);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user