diff options
author | Max Kellermann <max@duempel.org> | 2009-01-25 14:11:47 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-25 14:11:47 +0100 |
commit | 98cb8f3969de6b0151d2777b2344d6ff8fd44f1b (patch) | |
tree | af21157bb4ee43d0198c1cfb3cea740f3aaa0d93 /src/playlist.c | |
parent | 69c74afa2512747122880c35ac685d319057ab6d (diff) | |
download | mpd-98cb8f3969de6b0151d2777b2344d6ff8fd44f1b.tar.gz mpd-98cb8f3969de6b0151d2777b2344d6ff8fd44f1b.tar.xz mpd-98cb8f3969de6b0151d2777b2344d6ff8fd44f1b.zip |
playlist: moved savePlaylist() and loadPlaylsit() to playlist_save.c
Diffstat (limited to '')
-rw-r--r-- | src/playlist.c | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/src/playlist.c b/src/playlist.c index 57d0771dc..04cb59f3c 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -1025,38 +1025,6 @@ void shufflePlaylist(void) incrPlaylistVersion(); } -enum playlist_result savePlaylist(const char *utf8file) -{ - FILE *fp; - char *path; - - if (!is_valid_playlist_name(utf8file)) - return PLAYLIST_RESULT_BAD_NAME; - - path = map_spl_utf8_to_fs(utf8file); - if (path == NULL) - return PLAYLIST_RESULT_DISABLED; - - if (g_file_test(path, G_FILE_TEST_EXISTS)) { - g_free(path); - return PLAYLIST_RESULT_LIST_EXISTS; - } - - while (!(fp = fopen(path, "w")) && errno == EINTR); - g_free(path); - - if (fp == NULL) - return PLAYLIST_RESULT_ERRNO; - - for (unsigned i = 0; i < queue_length(&playlist.queue); i++) - playlist_print_song(fp, queue_get(&playlist.queue, i)); - - while (fclose(fp) && errno == EINTR) ; - - idle_add(IDLE_STORED_PLAYLIST); - return PLAYLIST_RESULT_SUCCESS; -} - int getPlaylistCurrentSong(void) { if (playlist.current >= 0) @@ -1124,35 +1092,6 @@ unsigned getPlaylistSongId(unsigned song) return queue_position_to_id(&playlist.queue, song); } -enum playlist_result loadPlaylist(const char *utf8file) -{ - GPtrArray *list; - - if (!(list = spl_load(utf8file))) - return PLAYLIST_RESULT_NO_SUCH_LIST; - - for (unsigned i = 0; i < list->len; ++i) { - const char *temp = g_ptr_array_index(list, i); - if ((addToPlaylist(temp, NULL)) != PLAYLIST_RESULT_SUCCESS) { - /* for windows compatibility, convert slashes */ - char *temp2 = g_strdup(temp); - char *p = temp2; - while (*p) { - if (*p == '\\') - *p = '/'; - p++; - } - if ((addToPlaylist(temp, NULL)) != PLAYLIST_RESULT_SUCCESS) { - g_warning("can't add file \"%s\"", temp2); - } - free(temp2); - } - } - - spl_free(list); - return PLAYLIST_RESULT_SUCCESS; -} - /* * Not supporting '/' was done out of laziness, and we should really * strive to support it in the future. |