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
c779e267
Commit
c779e267
authored
Sep 13, 2011
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db_visitor: add method playlist()
parent
a94d4be4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
0 deletions
+54
-0
db_print.c
src/db_print.c
+37
-0
db_visitor.h
src/db_visitor.h
+9
-0
directory.c
src/directory.c
+8
-0
No files found.
src/db_print.c
View file @
c779e267
...
...
@@ -72,14 +72,51 @@ print_visitor_song_info(struct song *song, void *data,
return
true
;
}
static
bool
print_visitor_playlist
(
const
struct
playlist_metadata
*
playlist
,
void
*
ctx
,
G_GNUC_UNUSED
GError
**
error_r
)
{
struct
client
*
client
=
ctx
;
client_printf
(
client
,
"playlist: %s
\n
"
,
playlist
->
name
);
return
true
;
}
static
bool
print_visitor_playlist_info
(
const
struct
playlist_metadata
*
playlist
,
void
*
ctx
,
G_GNUC_UNUSED
GError
**
error_r
)
{
struct
client
*
client
=
ctx
;
client_printf
(
client
,
"playlist: %s
\n
"
,
playlist
->
name
);
#ifndef G_OS_WIN32
struct
tm
tm
;
#endif
char
timestamp
[
32
];
time_t
t
=
playlist
->
mtime
;
strftime
(
timestamp
,
sizeof
(
timestamp
),
#ifdef G_OS_WIN32
"%Y-%m-%dT%H:%M:%SZ"
,
gmtime
(
&
t
)
#else
"%FT%TZ"
,
gmtime_r
(
&
t
,
&
tm
)
#endif
);
client_printf
(
client
,
"Last-Modified: %s
\n
"
,
timestamp
);
return
true
;
}
static
const
struct
db_visitor
print_visitor
=
{
.
directory
=
print_visitor_directory
,
.
song
=
print_visitor_song
,
.
playlist
=
print_visitor_playlist
,
};
static
const
struct
db_visitor
print_info_visitor
=
{
.
directory
=
print_visitor_directory
,
.
song
=
print_visitor_song_info
,
.
playlist
=
print_visitor_playlist_info
,
};
struct
search_data
{
...
...
src/db_visitor.h
View file @
c779e267
...
...
@@ -22,6 +22,7 @@
struct
directory
;
struct
song
;
struct
playlist_metadata
;
struct
db_visitor
{
/**
...
...
@@ -38,6 +39,14 @@ struct db_visitor {
* @return true to continue the operation, false on error (set error_r)
*/
bool
(
*
song
)(
struct
song
*
song
,
void
*
ctx
,
GError
**
error_r
);
/**
* Visit a playlist. Optional method.
*
* @return true to continue the operation, false on error (set error_r)
*/
bool
(
*
playlist
)(
const
struct
playlist_metadata
*
playlist
,
void
*
ctx
,
GError
**
error_r
);
};
#endif
src/directory.c
View file @
c779e267
...
...
@@ -184,6 +184,14 @@ directory_walk(const struct directory *directory, bool recursive,
return
false
;
}
if
(
visitor
->
playlist
!=
NULL
)
{
const
struct
playlist_vector
*
pv
=
&
directory
->
playlists
;
for
(
const
struct
playlist_metadata
*
i
=
pv
->
head
;
i
!=
NULL
;
i
=
i
->
next
)
if
(
!
visitor
->
playlist
(
i
,
ctx
,
error_r
))
return
false
;
}
const
struct
dirvec
*
dv
=
&
directory
->
children
;
for
(
size_t
i
=
0
;
i
<
dv
->
nr
;
++
i
)
{
struct
directory
*
child
=
dv
->
base
[
i
];
...
...
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