Commit df563db2 authored by Max Kellermann's avatar Max Kellermann

song: add function song_replace_uri()

parent 01b0d9eb
...@@ -61,6 +61,18 @@ song_file_new(const char *path, struct directory *parent) ...@@ -61,6 +61,18 @@ song_file_new(const char *path, struct directory *parent)
return song_alloc(path, parent); return song_alloc(path, parent);
} }
struct song *
song_replace_uri(struct song *old_song, const char *uri)
{
struct song *new_song = song_alloc(uri, old_song->parent);
new_song->tag = old_song->tag;
new_song->mtime = old_song->mtime;
new_song->start_ms = old_song->start_ms;
new_song->end_ms = old_song->end_ms;
g_free(old_song);
return new_song;
}
void void
song_free(struct song *song) song_free(struct song *song)
{ {
......
...@@ -74,6 +74,15 @@ song_file_new(const char *path, struct directory *parent); ...@@ -74,6 +74,15 @@ song_file_new(const char *path, struct directory *parent);
struct song * struct song *
song_file_load(const char *path, struct directory *parent); song_file_load(const char *path, struct directory *parent);
/**
* Replaces the URI of a song object. The given song object is
* destroyed, and a newly allocated one is returned. It does not
* update the reference within the parent directory; the caller is
* responsible for doing that.
*/
struct song *
song_replace_uri(struct song *song, const char *uri);
void void
song_free(struct song *song); song_free(struct song *song);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment