diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-09-01 17:16:55 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-01 17:16:55 -0700 |
commit | 36984e9e8c7ccb33f43a9f096e848d28e532dc6e (patch) | |
tree | c5f07e95d89e397e4df8d7246134ce7b007911cb | |
parent | c36029fc806cf083de3aaf1344d6bd2be8db316f (diff) | |
download | mpd-36984e9e8c7ccb33f43a9f096e848d28e532dc6e.tar.gz mpd-36984e9e8c7ccb33f43a9f096e848d28e532dc6e.tar.xz mpd-36984e9e8c7ccb33f43a9f096e848d28e532dc6e.zip |
storedPlaylist: correctly expand path when writing
Otherwise we'd be writing to whatever directory that mpd is
running in.
Diffstat (limited to '')
-rw-r--r-- | src/storedPlaylist.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/storedPlaylist.c b/src/storedPlaylist.c index a38511ea1..332f99456 100644 --- a/src/storedPlaylist.c +++ b/src/storedPlaylist.c @@ -60,26 +60,27 @@ static ListNode *nodeOfStoredPlaylist(List *list, int idx) return NULL; } -static int writeStoredPlaylistToPath(int fd, List *list, const char *fspath) +static int writeStoredPlaylistToPath(int fd, List *list, const char *utf8path) { ListNode *node; FILE *file; char *s; + char path_max_tmp[MPD_PATH_MAX]; - if (fspath == NULL) + if (!utf8path || !valid_playlist_name(fd, utf8path)) return -1; - while (!(file = fopen(fspath, "w")) && errno == EINTR); + utf8_to_fs_playlist_path(path_max_tmp, utf8path); + + while (!(file = fopen(path_max_tmp, "w")) && errno == EINTR); if (file == NULL) { commandError(fd, ACK_ERROR_NO_EXIST, "could not open file " - "\"%s\": %s", fspath, strerror(errno)); + "\"%s\": %s", path_max_tmp, strerror(errno)); return -1; } node = list->firstNode; while (node != NULL) { - char path_max_tmp[MPD_PATH_MAX]; - s = utf8_to_fs_charset(path_max_tmp, (char *)node->data); if (playlist_saveAbsolutePaths && !isValidRemoteUtf8Url(s)) s = rmp2amp_r(path_max_tmp, s); |