Commit 35494158 authored by Eric Wong's avatar Eric Wong Committed by Max Kellermann

storedPlaylist: correctly expand path when writing

Otherwise we'd be writing to whatever directory that mpd is running in.
parent 5c81b716
...@@ -59,22 +59,23 @@ static ListNode *nodeOfStoredPlaylist(List *list, int idx) ...@@ -59,22 +59,23 @@ static ListNode *nodeOfStoredPlaylist(List *list, int idx)
} }
static enum playlist_result static enum playlist_result
writeStoredPlaylistToPath(List *list, const char *fspath) writeStoredPlaylistToPath(List *list, const char *utf8path)
{ {
ListNode *node; ListNode *node;
FILE *file; FILE *file;
char *s; char *s;
char path_max_tmp[MPD_PATH_MAX];
assert(utf8path != NULL);
assert(fspath != NULL); utf8_to_fs_playlist_path(path_max_tmp, utf8path);
while (!(file = fopen(fspath, "w")) && errno == EINTR); while (!(file = fopen(path_max_tmp, "w")) && errno == EINTR);
if (file == NULL) if (file == NULL)
return PLAYLIST_RESULT_ERRNO; return PLAYLIST_RESULT_ERRNO;
node = list->firstNode; node = list->firstNode;
while (node != NULL) { while (node != NULL) {
char path_max_tmp[MPD_PATH_MAX];
s = utf8_to_fs_charset(path_max_tmp, (char *)node->data); s = utf8_to_fs_charset(path_max_tmp, (char *)node->data);
if (playlist_saveAbsolutePaths && !isValidRemoteUtf8Url(s)) if (playlist_saveAbsolutePaths && !isValidRemoteUtf8Url(s))
s = rmp2amp_r(path_max_tmp, s); s = rmp2amp_r(path_max_tmp, s);
......
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