Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
fc094c08
Commit
fc094c08
authored
May 25, 2007
by
J. Alexander Treuman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaning up formatting and error messages in storedPlaylist.c.
git-svn-id:
https://svn.musicpd.org/mpd/trunk@6263
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
2814b7cf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
63 deletions
+25
-63
storedPlaylist.c
src/storedPlaylist.c
+25
-63
No files found.
src/storedPlaylist.c
View file @
fc094c08
...
...
@@ -113,15 +113,11 @@ StoredPlaylist *newStoredPlaylist(const char *utf8name, int fd, int ignoreExisti
if
(
utf8name
)
{
filename
=
utf8pathToFsPathInStoredPlaylist
(
utf8name
,
fd
);
if
(
filename
&&
stat
(
filename
,
&
buf
)
==
0
&&
ignoreExisting
==
0
)
{
if
(
fd
!=
-
1
)
commandError
(
fd
,
ACK_ERROR_EXIST
,
"a file or directory already "
"exists with the name
\"
%s
\"
"
,
utf8name
);
ERROR
(
"a file or directory already exists with the "
"name
\"
%s
\"\n
"
,
utf8name
);
if
(
filename
&&
stat
(
filename
,
&
buf
)
==
0
&&
ignoreExisting
==
0
)
{
commandError
(
fd
,
ACK_ERROR_EXIST
,
"a file or directory already exists with "
"the name
\"
%s
\"
"
,
utf8name
);
free
(
sp
);
return
NULL
;
...
...
@@ -340,20 +336,13 @@ int removeAllFromStoredPlaylistByPath(int fd, const char *utf8path)
FILE
*
file
;
filename
=
utf8pathToFsPathInStoredPlaylist
(
utf8path
,
fd
);
if
(
!
filename
)
{
if
(
!
filename
)
return
-
1
;
}
while
(
!
(
file
=
fopen
(
filename
,
"w"
))
&&
errno
==
EINTR
);
if
(
file
==
NULL
)
{
if
(
fd
!=
-
1
)
{
commandError
(
fd
,
ACK_ERROR_NO_EXIST
,
"could not open file
\"
%s
\"
: %s"
,
filename
,
strerror
(
errno
));
}
ERROR
(
"could not open file
\"
%s
\"
: %s
\n
"
,
filename
,
strerror
(
errno
));
commandError
(
fd
,
ACK_ERROR_NO_EXIST
,
"could not open file "
"
\"
%s
\"
: %s"
,
filename
,
strerror
(
errno
));
return
-
1
;
}
...
...
@@ -365,8 +354,8 @@ static int removeOneSongFromStoredPlaylist(int fd, StoredPlaylist *sp, int pos)
{
ListNode
*
node
=
nodeOfStoredPlaylist
(
sp
,
pos
);
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
;
}
...
...
@@ -439,11 +428,10 @@ static void appendSongToStoredPlaylist(StoredPlaylist *sp, Song *song)
{
char
*
s
;
if
(
playlist_saveAbsolutePaths
&&
song
->
type
==
SONG_TYPE_FILE
)
{
if
(
playlist_saveAbsolutePaths
&&
song
->
type
==
SONG_TYPE_FILE
)
s
=
rmp2amp
(
utf8ToFsCharset
(
getSongUrl
(
song
)));
}
else
{
else
s
=
utf8ToFsCharset
(
getSongUrl
(
song
));
}
insertInListWithoutKey
(
sp
->
list
,
strdup
(
s
));
}
...
...
@@ -454,29 +442,20 @@ int appendSongToStoredPlaylistByPath(int fd, const char *utf8path, Song *song)
FILE
*
file
;
filename
=
utf8pathToFsPathInStoredPlaylist
(
utf8path
,
fd
);
if
(
!
filename
)
{
if
(
!
filename
)
return
-
1
;
}
while
(
!
(
file
=
fopen
(
filename
,
"a"
))
&&
errno
==
EINTR
);
if
(
file
==
NULL
)
{
if
(
fd
!=
-
1
)
{
commandError
(
fd
,
ACK_ERROR_NO_EXIST
,
"Could not open file
\"
%s
\"
: %s"
,
filename
,
strerror
(
errno
));
}
ERROR
(
"could not open file
\"
%s
\"
: %s
\n
"
,
filename
,
strerror
(
errno
));
commandError
(
fd
,
ACK_ERROR_NO_EXIST
,
"could not open file "
"
\"
%s
\"
: %s"
,
filename
,
strerror
(
errno
));
return
-
1
;
}
if
(
playlist_saveAbsolutePaths
&&
song
->
type
==
SONG_TYPE_FILE
)
{
if
(
playlist_saveAbsolutePaths
&&
song
->
type
==
SONG_TYPE_FILE
)
fprintf
(
file
,
"%s
\n
"
,
rmp2amp
(
utf8ToFsCharset
(
getSongUrl
(
song
))));
}
else
{
else
fprintf
(
file
,
"%s
\n
"
,
utf8ToFsCharset
(
getSongUrl
(
song
)));
}
while
(
fclose
(
file
)
!=
0
&&
errno
==
EINTR
);
return
0
;
...
...
@@ -485,9 +464,8 @@ int appendSongToStoredPlaylistByPath(int fd, const char *utf8path, Song *song)
void
appendPlaylistToStoredPlaylist
(
StoredPlaylist
*
sp
,
Playlist
*
playlist
)
{
int
i
;
for
(
i
=
0
;
i
<
playlist
->
length
;
i
++
)
{
for
(
i
=
0
;
i
<
playlist
->
length
;
i
++
)
appendSongToStoredPlaylist
(
sp
,
playlist
->
songs
[
i
]);
}
}
int
renameStoredPlaylist
(
int
fd
,
const
char
*
utf8from
,
const
char
*
utf8to
)
...
...
@@ -508,41 +486,25 @@ int renameStoredPlaylist(int fd, const char *utf8from, const char *utf8to)
}
if
(
stat
(
from
,
&
st
)
!=
0
)
{
if
(
fd
!=
-
1
)
{
commandError
(
fd
,
ACK_ERROR_NO_EXIST
,
"no playlist named
\"
%s
\"
"
,
utf8from
);
}
ERROR
(
"no playlist named
\"
%s
\"\n
"
,
utf8from
);
commandError
(
fd
,
ACK_ERROR_NO_EXIST
,
"no playlist named
\"
%s
\"
"
,
utf8from
);
ret
=
-
1
;
goto
out
;
}
if
(
stat
(
to
,
&
st
)
==
0
)
{
if
(
fd
!=
-
1
)
{
commandError
(
fd
,
ACK_ERROR_EXIST
,
"a file or directory "
"already exists with the name
\"
%s
\"
"
,
utf8to
);
}
ERROR
(
"a file or directory already exists with the "
"name
\"
%s
\"\n
"
,
utf8to
);
commandError
(
fd
,
ACK_ERROR_EXIST
,
"a file or directory "
"already exists with the name
\"
%s
\"
"
,
utf8to
);
ret
=
-
1
;
goto
out
;
}
if
(
rename
(
from
,
to
)
<
0
)
{
if
(
fd
!=
-
1
)
{
commandError
(
fd
,
ACK_ERROR_UNKNOWN
,
"could not rename playlist
\"
%s
\"
to "
"
\"
%s
\"
: %s"
,
utf8from
,
utf8to
,
strerror
(
errno
));
}
ERROR
(
"could not rename playlist
\"
%s
\"
to
\"
%s
\"
: %s
\n
"
,
utf8from
,
utf8to
,
strerror
(
errno
));
commandError
(
fd
,
ACK_ERROR_UNKNOWN
,
"could not rename playlist
\"
%s
\"
to
\"
%s
\"
: %s"
,
utf8from
,
utf8to
,
strerror
(
errno
));
ret
=
-
1
;
goto
out
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment