playlist: cleanup pathname generation for the "rm" command, too
git-svn-id: https://svn.musicpd.org/mpd/trunk@7117 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
@@ -1388,26 +1388,16 @@ int shufflePlaylist(int fd)
|
|||||||
int deletePlaylist(int fd, char *utf8file)
|
int deletePlaylist(int fd, char *utf8file)
|
||||||
{
|
{
|
||||||
char path_max_tmp[MPD_PATH_MAX];
|
char path_max_tmp[MPD_PATH_MAX];
|
||||||
char *file = utf8_to_fs_charset(path_max_tmp, utf8file);
|
|
||||||
char *rfile = xmalloc(strlen(file) + strlen(".") +
|
|
||||||
strlen(PLAYLIST_FILE_SUFFIX) + 1);
|
|
||||||
char *actualFile;
|
|
||||||
|
|
||||||
strcpy(rfile, file);
|
utf8_to_fs_playlist_path(path_max_tmp, utf8file);
|
||||||
strcat(rfile, ".");
|
|
||||||
strcat(rfile, PLAYLIST_FILE_SUFFIX);
|
|
||||||
|
|
||||||
actualFile = rpp2app_r(path_max_tmp, rfile);
|
if (!isPlaylist(path_max_tmp)) {
|
||||||
if (isPlaylist(actualFile))
|
|
||||||
free(rfile);
|
|
||||||
else {
|
|
||||||
free(rfile);
|
|
||||||
commandError(fd, ACK_ERROR_NO_EXIST,
|
commandError(fd, ACK_ERROR_NO_EXIST,
|
||||||
"playlist \"%s\" not found", utf8file);
|
"playlist \"%s\" not found", utf8file);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlink(actualFile) < 0) {
|
if (unlink(path_max_tmp) < 0) {
|
||||||
commandError(fd, ACK_ERROR_SYSTEM,
|
commandError(fd, ACK_ERROR_SYSTEM,
|
||||||
"problems deleting file");
|
"problems deleting file");
|
||||||
return -1;
|
return -1;
|
||||||
|
Reference in New Issue
Block a user