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
7ba357a0
Commit
7ba357a0
authored
May 24, 2007
by
J. Alexander Treuman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding rename command, for renaming stored playlists.
git-svn-id:
https://svn.musicpd.org/mpd/trunk@6246
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
0d7d2ebf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
0 deletions
+75
-0
ChangeLog
ChangeLog
+1
-0
command.c
src/command.c
+7
-0
storedPlaylist.c
src/storedPlaylist.c
+65
-0
storedPlaylist.h
src/storedPlaylist.h
+2
-0
No files found.
ChangeLog
View file @
7ba357a0
...
...
@@ -20,6 +20,7 @@ ver 0.13.0 (2007/??/??)
* New count command for getting stats on found songs (similar to "find")
* New playlistmove command for moving songs in stored playlists
* New playlistdelete command for deleting songs from stored playlists
* New rename command for renaming stored playlists
* Lots of bug fixes, cleaned up code, and performance improvements
ver 0.12.2 (2007/3/20)
...
...
src/command.c
View file @
7ba357a0
...
...
@@ -100,6 +100,7 @@
#define COMMAND_PLAYLISTDELETE "playlistdelete"
#define COMMAND_TAGTYPES "tagtypes"
#define COMMAND_COUNT "count"
#define COMMAND_RENAME "rename"
#define COMMAND_STATUS_VOLUME "volume"
#define COMMAND_STATUS_STATE "state"
...
...
@@ -421,6 +422,11 @@ static int handleRm(int fd, int *permission, int argc, char *argv[])
return
deletePlaylist
(
fd
,
argv
[
1
]);
}
static
int
handleRename
(
int
fd
,
int
*
permission
,
int
argc
,
char
*
argv
[])
{
return
renameStoredPlaylist
(
fd
,
argv
[
1
],
argv
[
2
]);
}
static
int
handlePlaylistChanges
(
int
fd
,
int
*
permission
,
int
argc
,
char
*
argv
[])
{
...
...
@@ -1117,6 +1123,7 @@ void initCommands(void)
addCommand
(
COMMAND_PLAYLISTDELETE
,
PERMISSION_CONTROL
,
2
,
2
,
handlePlaylistDelete
,
NULL
);
addCommand
(
COMMAND_TAGTYPES
,
PERMISSION_READ
,
0
,
0
,
handleTagTypes
,
NULL
);
addCommand
(
COMMAND_COUNT
,
PERMISSION_READ
,
2
,
-
1
,
handleCount
,
NULL
);
addCommand
(
COMMAND_RENAME
,
PERMISSION_CONTROL
,
2
,
2
,
handleRename
,
NULL
);
sortList
(
commandList
);
}
...
...
src/storedPlaylist.c
View file @
7ba357a0
...
...
@@ -489,3 +489,68 @@ void appendPlaylistToStoredPlaylist(StoredPlaylist *sp, Playlist *playlist)
appendSongToStoredPlaylist
(
sp
,
playlist
->
songs
[
i
]);
}
}
int
renameStoredPlaylist
(
int
fd
,
const
char
*
utf8from
,
const
char
*
utf8to
)
{
struct
stat
st
;
char
*
from
;
char
*
to
;
int
ret
=
0
;
from
=
xstrdup
(
utf8pathToFsPathInStoredPlaylist
(
utf8from
,
fd
));
if
(
!
from
)
return
-
1
;
to
=
xstrdup
(
utf8pathToFsPathInStoredPlaylist
(
utf8to
,
fd
));
if
(
!
to
)
{
free
(
from
);
return
-
1
;
}
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
);
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
);
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
));
ret
=
-
1
;
goto
out
;
}
out:
free
(
from
);
free
(
to
);
return
ret
;
}
src/storedPlaylist.h
View file @
7ba357a0
...
...
@@ -43,4 +43,6 @@ int writeStoredPlaylist(StoredPlaylist *sp);
int
appendSongToStoredPlaylistByPath
(
int
fd
,
const
char
*
utf8path
,
Song
*
song
);
void
appendPlaylistToStoredPlaylist
(
StoredPlaylist
*
sp
,
Playlist
*
playlist
);
int
renameStoredPlaylist
(
int
fd
,
const
char
*
utf8from
,
const
char
*
utf8to
);
#endif
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