Cleaning up error messages in storedPlaylist.c.
git-svn-id: https://svn.musicpd.org/mpd/trunk@6245 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
c408bd5e90
commit
0d7d2ebf80
@ -35,13 +35,14 @@ static char *utf8pathToFsPathInStoredPlaylist(const char *utf8path, int fd)
|
|||||||
|
|
||||||
if (strstr(utf8path, "/")) {
|
if (strstr(utf8path, "/")) {
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
commandError(fd, ACK_ERROR_ARG,
|
commandError(fd, ACK_ERROR_ARG, "playlist name \"%s\" "
|
||||||
"Cannot clear \"%s\", saving playlists to "
|
"is invalid: playlist names may not "
|
||||||
"subdirectories is not supported", utf8path);
|
"contain slashes", utf8path);
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR("Cannot clear \"%s\", saving playlists to "
|
ERROR("playlist name \"%s\" is invalid: playlist names may not "
|
||||||
"subdirectories is not supported", utf8path);
|
"contain slashes\n", utf8path);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,11 +116,12 @@ StoredPlaylist *newStoredPlaylist(const char *utf8name, int fd, int ignoreExisti
|
|||||||
if (filename && stat(filename, &buf) == 0 && ignoreExisting == 0) {
|
if (filename && stat(filename, &buf) == 0 && ignoreExisting == 0) {
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
commandError(fd, ACK_ERROR_EXIST,
|
commandError(fd, ACK_ERROR_EXIST,
|
||||||
"a file or directory already "
|
"a file or directory already "
|
||||||
"exists with the name \"%s\"", utf8name);
|
"exists with the name \"%s\"",
|
||||||
|
utf8name);
|
||||||
|
|
||||||
ERROR("a file or directory already "
|
ERROR("a file or directory already exists with the "
|
||||||
"exists with the name \"%s\"", utf8name);
|
"name \"%s\"\n", utf8name);
|
||||||
|
|
||||||
free(sp);
|
free(sp);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -156,10 +158,13 @@ StoredPlaylist *loadStoredPlaylist(const char *utf8path, int fd)
|
|||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
commandError(fd, ACK_ERROR_NO_EXIST,
|
commandError(fd, ACK_ERROR_NO_EXIST,
|
||||||
"Could not open file \"%s\": %s", filename, strerror(errno));
|
"could not open file \"%s\": %s", filename,
|
||||||
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR("Could not open file \"%s\": %s", filename, strerror(errno));
|
ERROR("could not open file \"%s\": %s\n", filename,
|
||||||
|
strerror(errno));
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,10 +192,10 @@ StoredPlaylist *loadStoredPlaylist(const char *utf8path, int fd)
|
|||||||
if (strlen(s) >= MAXPATHLEN) {
|
if (strlen(s) >= MAXPATHLEN) {
|
||||||
if (sp->fd != -1) {
|
if (sp->fd != -1) {
|
||||||
commandError(sp->fd, ACK_ERROR_PLAYLIST_LOAD,
|
commandError(sp->fd, ACK_ERROR_PLAYLIST_LOAD,
|
||||||
"\"%s\" too long", temp);
|
"\"%s\" is too long", temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR("\"%s\" too long", temp);
|
ERROR("\"%s\" is too long\n", temp);
|
||||||
free(temp);
|
free(temp);
|
||||||
freeStoredPlaylist(sp);
|
freeStoredPlaylist(sp);
|
||||||
sp = NULL;
|
sp = NULL;
|
||||||
@ -209,10 +214,11 @@ StoredPlaylist *loadStoredPlaylist(const char *utf8path, int fd)
|
|||||||
s[slength] = '\0';
|
s[slength] = '\0';
|
||||||
if (sp->fd != -1) {
|
if (sp->fd != -1) {
|
||||||
commandError(sp->fd, ACK_ERROR_PLAYLIST_LOAD,
|
commandError(sp->fd, ACK_ERROR_PLAYLIST_LOAD,
|
||||||
"line \"%s\" in playlist \"%s\" is too long\n",
|
"line \"%s\" in playlist \"%s\" "
|
||||||
s, utf8path);
|
"is too long", s, utf8path);
|
||||||
}
|
}
|
||||||
ERROR("line \"%s\" in playlist \"%s\" is too long\n", s, utf8path);
|
ERROR("line \"%s\" in playlist \"%s\" is too long\n", s,
|
||||||
|
utf8path);
|
||||||
freeStoredPlaylist(sp);
|
freeStoredPlaylist(sp);
|
||||||
sp = NULL;
|
sp = NULL;
|
||||||
goto out;
|
goto out;
|
||||||
@ -240,7 +246,7 @@ static int moveSongInStoredPlaylist(int fd, StoredPlaylist *sp, int src, int des
|
|||||||
ListNode *srcNode, *destNode;
|
ListNode *srcNode, *destNode;
|
||||||
|
|
||||||
if (src >= lengthOfStoredPlaylist(sp) || dest >= lengthOfStoredPlaylist(sp) || src < 0 || dest < 0 || src == dest) {
|
if (src >= lengthOfStoredPlaylist(sp) || dest >= lengthOfStoredPlaylist(sp) || src < 0 || dest < 0 || src == dest) {
|
||||||
commandError(fd, ACK_ERROR_ARG, "argument out of range.");
|
commandError(fd, ACK_ERROR_ARG, "argument out of range");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +306,7 @@ int moveSongInStoredPlaylistByPath(int fd, const char *utf8path, int src, int de
|
|||||||
{
|
{
|
||||||
StoredPlaylist *sp = loadStoredPlaylist(utf8path, fd);
|
StoredPlaylist *sp = loadStoredPlaylist(utf8path, fd);
|
||||||
if (!sp) {
|
if (!sp) {
|
||||||
commandError(fd, ACK_ERROR_UNKNOWN, "could not open playlist.");
|
commandError(fd, ACK_ERROR_UNKNOWN, "could not open playlist");
|
||||||
freeStoredPlaylist(sp);
|
freeStoredPlaylist(sp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -311,7 +317,7 @@ int moveSongInStoredPlaylistByPath(int fd, const char *utf8path, int src, int de
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (writeStoredPlaylist(sp) != 0) {
|
if (writeStoredPlaylist(sp) != 0) {
|
||||||
commandError(fd, ACK_ERROR_UNKNOWN, "failed to save playlist.");
|
commandError(fd, ACK_ERROR_UNKNOWN, "failed to save playlist");
|
||||||
freeStoredPlaylist(sp);
|
freeStoredPlaylist(sp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -342,10 +348,12 @@ int removeAllFromStoredPlaylistByPath(int fd, const char *utf8path)
|
|||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
commandError(fd, ACK_ERROR_NO_EXIST,
|
commandError(fd, ACK_ERROR_NO_EXIST,
|
||||||
"Could not open file \"%s\": %s", filename, strerror(errno));
|
"could not open file \"%s\": %s", filename,
|
||||||
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR("Could not open file \"%s\": %s", filename, strerror(errno));
|
ERROR("could not open file \"%s\": %s\n", filename,
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,7 +365,8 @@ static int removeOneSongFromStoredPlaylist(int fd, StoredPlaylist *sp, int pos)
|
|||||||
{
|
{
|
||||||
ListNode *node = nodeOfStoredPlaylist(sp, pos);
|
ListNode *node = nodeOfStoredPlaylist(sp, pos);
|
||||||
if (!node) {
|
if (!node) {
|
||||||
commandError(fd, ACK_ERROR_ARG, "could not find song at position.");
|
commandError(fd, ACK_ERROR_ARG, "could not find song at "
|
||||||
|
"position");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,7 +379,7 @@ int removeOneSongFromStoredPlaylistByPath(int fd, const char *utf8path, int pos)
|
|||||||
{
|
{
|
||||||
StoredPlaylist *sp = loadStoredPlaylist(utf8path, fd);
|
StoredPlaylist *sp = loadStoredPlaylist(utf8path, fd);
|
||||||
if (!sp) {
|
if (!sp) {
|
||||||
commandError(fd, ACK_ERROR_UNKNOWN, "could not open playlist.");
|
commandError(fd, ACK_ERROR_UNKNOWN, "could not open playlist");
|
||||||
freeStoredPlaylist(sp);
|
freeStoredPlaylist(sp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -381,7 +390,7 @@ int removeOneSongFromStoredPlaylistByPath(int fd, const char *utf8path, int pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (writeStoredPlaylist(sp) != 0) {
|
if (writeStoredPlaylist(sp) != 0) {
|
||||||
commandError(fd, ACK_ERROR_UNKNOWN, "failed to save playlist.");
|
commandError(fd, ACK_ERROR_UNKNOWN, "failed to save playlist");
|
||||||
freeStoredPlaylist(sp);
|
freeStoredPlaylist(sp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -402,10 +411,12 @@ static int writeStoredPlaylistToPath(StoredPlaylist *sp, const char *fspath)
|
|||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
if (sp->fd != -1) {
|
if (sp->fd != -1) {
|
||||||
commandError(sp->fd, ACK_ERROR_NO_EXIST,
|
commandError(sp->fd, ACK_ERROR_NO_EXIST,
|
||||||
"Could not open file \"%s\": %s", fspath, strerror(errno));
|
"could not open file \"%s\": %s", fspath,
|
||||||
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR("Couldn't open file \"%s\": %s", fspath, strerror(errno));
|
ERROR("could not open file \"%s\": %s\n", fspath,
|
||||||
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,10 +462,13 @@ int appendSongToStoredPlaylistByPath(int fd, const char *utf8path, Song *song)
|
|||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
commandError(fd, ACK_ERROR_NO_EXIST,
|
commandError(fd, ACK_ERROR_NO_EXIST,
|
||||||
"Could not open file \"%s\": %s", filename, strerror(errno));
|
"Could not open file \"%s\": %s", filename,
|
||||||
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR("Could not open file \"%s\": %s", filename, strerror(errno));
|
ERROR("could not open file \"%s\": %s\n", filename,
|
||||||
|
strerror(errno));
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user