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
f9e0f0d2
Commit
f9e0f0d2
authored
Mar 24, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PlaylistSave: return bool/Error instead of PlaylistResult
parent
98f3135a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
24 deletions
+28
-24
PlaylistSave.cxx
src/PlaylistSave.cxx
+19
-18
PlaylistSave.hxx
src/PlaylistSave.hxx
+5
-4
PlaylistCommands.cxx
src/command/PlaylistCommands.cxx
+4
-2
No files found.
src/PlaylistSave.cxx
View file @
f9e0f0d2
...
...
@@ -65,26 +65,26 @@ playlist_print_uri(FILE *file, const char *uri)
fprintf
(
file
,
"%s
\n
"
,
NarrowPath
(
path
).
c_str
());
}
PlaylistResult
spl_save_queue
(
const
char
*
name_utf8
,
const
Queue
&
queue
)
bool
spl_save_queue
(
const
char
*
name_utf8
,
const
Queue
&
queue
,
Error
&
error
)
{
if
(
map_spl_path
().
IsNull
())
return
PlaylistResult
::
DISABLED
;
if
(
!
spl_valid_name
(
name_utf8
))
return
PlaylistResult
::
BAD_NAME
;
const
auto
path_fs
=
map_spl_utf8_to_fs
(
name_utf8
);
const
auto
path_fs
=
spl_map_to_fs
(
name_utf8
,
error
);
if
(
path_fs
.
IsNull
())
return
PlaylistResult
::
BAD_NAME
;
return
false
;
if
(
FileExists
(
path_fs
))
return
PlaylistResult
::
LIST_EXISTS
;
if
(
FileExists
(
path_fs
))
{
error
.
Set
(
playlist_domain
,
int
(
PlaylistResult
::
LIST_EXISTS
),
"Playlist already exists"
);
return
false
;
}
FILE
*
file
=
FOpen
(
path_fs
,
FOpenMode
::
WriteText
);
if
(
file
==
nullptr
)
return
PlaylistResult
::
ERRNO
;
if
(
file
==
nullptr
)
{
error
.
FormatErrno
(
"Failed to open %s"
,
path_fs
.
ToUTF8
().
c_str
());
return
false
;
}
for
(
unsigned
i
=
0
;
i
<
queue
.
GetLength
();
i
++
)
playlist_print_song
(
file
,
queue
.
Get
(
i
));
...
...
@@ -92,11 +92,12 @@ spl_save_queue(const char *name_utf8, const Queue &queue)
fclose
(
file
);
idle_add
(
IDLE_STORED_PLAYLIST
);
return
PlaylistResult
::
SUCCESS
;
return
true
;
}
PlaylistResult
spl_save_playlist
(
const
char
*
name_utf8
,
const
playlist
&
playlist
)
bool
spl_save_playlist
(
const
char
*
name_utf8
,
const
playlist
&
playlist
,
Error
&
error
)
{
return
spl_save_queue
(
name_utf8
,
playlist
.
queue
);
return
spl_save_queue
(
name_utf8
,
playlist
.
queue
,
error
);
}
src/PlaylistSave.hxx
View file @
f9e0f0d2
...
...
@@ -39,13 +39,14 @@ playlist_print_uri(FILE *fp, const char *uri);
/**
* Saves a queue object into a stored playlist file.
*/
PlaylistResult
spl_save_queue
(
const
char
*
name_utf8
,
const
Queue
&
queue
);
bool
spl_save_queue
(
const
char
*
name_utf8
,
const
Queue
&
queue
,
Error
&
error
);
/**
* Saves a playlist object into a stored playlist file.
*/
PlaylistResult
spl_save_playlist
(
const
char
*
name_utf8
,
const
playlist
&
playlist
);
bool
spl_save_playlist
(
const
char
*
name_utf8
,
const
playlist
&
playlist
,
Error
&
error
);
#endif
src/command/PlaylistCommands.cxx
View file @
f9e0f0d2
...
...
@@ -61,8 +61,10 @@ print_spl_list(Client &client, const PlaylistVector &list)
CommandResult
handle_save
(
Client
&
client
,
ConstBuffer
<
const
char
*>
args
)
{
PlaylistResult
result
=
spl_save_playlist
(
args
.
front
(),
client
.
playlist
);
return
print_playlist_result
(
client
,
result
);
Error
error
;
return
spl_save_playlist
(
args
.
front
(),
client
.
playlist
,
error
)
?
CommandResult
::
OK
:
print_error
(
client
,
error
);
}
CommandResult
...
...
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