diff options
author | Max Kellermann <max@duempel.org> | 2008-09-07 14:02:43 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-07 14:02:43 +0200 |
commit | 709ec6fa39e031953f64bab6c3e84d7688e04632 (patch) | |
tree | 87dff1a888b0557eb3ee5e455f448e1252f14fcb /src | |
parent | 438b56f0bab3e814185d2f3fa2f03df82829302a (diff) | |
download | mpd-709ec6fa39e031953f64bab6c3e84d7688e04632.tar.gz mpd-709ec6fa39e031953f64bab6c3e84d7688e04632.tar.xz mpd-709ec6fa39e031953f64bab6c3e84d7688e04632.zip |
playlist: added playlist_save()
The shared code in showPlaylist() isn't worth it, because we aim to
remove fdprintf(). Duplicate this small function, and enable stdio
buffering for saved playlists.
Diffstat (limited to 'src')
-rw-r--r-- | src/playlist.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/playlist.c b/src/playlist.c index 042907e16..a0b1be3e9 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -229,6 +229,16 @@ void showPlaylist(int fd) } } +static void playlist_save(FILE *fp) +{ + int i; + char path_max_tmp[MPD_PATH_MAX]; + + for (i = 0; i < playlist.length; i++) + fprintf(fp, "%i:%s\n", i, + get_song_url(path_max_tmp, playlist.songs[i])); +} + void savePlaylistState(FILE *fp) { fprintf(fp, "%s", PLAYLIST_STATE_FILE_STATE); @@ -255,8 +265,7 @@ void savePlaylistState(FILE *fp) fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE, (int)(getPlayerCrossFade())); fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN); - fflush(fp); - showPlaylist(fileno(fp)); + playlist_save(fp); fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END); } |