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
ab3d89f4
Commit
ab3d89f4
authored
Mar 08, 2009
by
Jochen Keil
Committed by
Max Kellermann
Mar 09, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder_plugin: added method container_scan()
[mk: fixed whitespace errors; use delete_song() instead of songvec_delete()]
parent
94d1a87d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
120 additions
and
4 deletions
+120
-4
sidplay_plugin.cxx
src/decoder/sidplay_plugin.cxx
+1
-0
decoder_plugin.h
src/decoder_plugin.h
+23
-0
directory.h
src/directory.h
+1
-0
file_input_plugin.c
src/input/file_input_plugin.c
+17
-2
update.c
src/update.c
+78
-2
No files found.
src/decoder/sidplay_plugin.cxx
View file @
ab3d89f4
...
...
@@ -156,6 +156,7 @@ const struct decoder_plugin sidplay_decoder_plugin = {
NULL
,
/* stream_decode() */
sidplay_file_decode
,
sidplay_tag_dup
,
NULL
,
/* container_scan */
sidplay_suffixes
,
NULL
,
/* mime_types */
};
src/decoder_plugin.h
View file @
ab3d89f4
...
...
@@ -74,6 +74,18 @@ struct decoder_plugin {
*/
struct
tag
*
(
*
tag_dup
)(
const
char
*
file
);
/**
* @brief Return a "virtual" filename for subtracks in
* container formats like flac
* @param const char* pathname full pathname for the file on fs
* @param const unsigned int tnum track number
*
* @return NULL if there are no multiple files
* a filename for every single track according to tnum (param 2)
* do not include full pathname here, just the "virtual" file
*/
char
*
(
*
container_scan
)(
const
char
*
pathname
,
const
unsigned
int
tnum
);
/* last element in these arrays must always be a NULL: */
const
char
*
const
*
suffixes
;
const
char
*
const
*
mime_types
;
...
...
@@ -136,4 +148,15 @@ decoder_plugin_tag_dup(const struct decoder_plugin *plugin,
return
plugin
->
tag_dup
(
path_fs
);
}
/**
* return "virtual" tracks in a container
*/
static
inline
char
*
decoder_plugin_container_scan
(
const
struct
decoder_plugin
*
plugin
,
const
char
*
pathname
,
const
unsigned
int
tnum
)
{
return
plugin
->
container_scan
(
pathname
,
tnum
);
}
#endif
src/directory.h
View file @
ab3d89f4
...
...
@@ -28,6 +28,7 @@
#define DIRECTORY_DIR "directory: "
#define DEVICE_INARCHIVE (unsigned)(-1)
#define DEVICE_CONTAINER (unsigned)(-2)
struct
directory
{
struct
dirvec
children
;
...
...
src/input/file_input_plugin.c
View file @
ab3d89f4
...
...
@@ -35,12 +35,23 @@ input_file_open(struct input_stream *is, const char *filename)
int
fd
,
ret
;
struct
stat
st
;
char
*
pathname
=
g_strdup
(
filename
);
if
(
filename
[
0
]
!=
'/'
)
{
g_free
(
pathname
);
return
false
;
}
fd
=
open
(
filename
,
O_RDONLY
);
if
(
stat
(
filename
,
&
st
)
<
0
)
{
char
*
slash
=
strrchr
(
pathname
,
'/'
);
*
slash
=
'\0'
;
}
fd
=
open
(
pathname
,
O_RDONLY
);
if
(
fd
<
0
)
{
is
->
error
=
errno
;
g_free
(
pathname
);
return
false
;
}
...
...
@@ -50,13 +61,15 @@ input_file_open(struct input_stream *is, const char *filename)
if
(
ret
<
0
)
{
is
->
error
=
errno
;
close
(
fd
);
g_free
(
pathname
);
return
false
;
}
if
(
!
S_ISREG
(
st
.
st_mode
))
{
g_debug
(
"Not a regular file: %s
\n
"
,
file
name
);
g_debug
(
"Not a regular file: %s
"
,
path
name
);
is
->
error
=
EINVAL
;
close
(
fd
);
g_free
(
pathname
);
return
false
;
}
...
...
@@ -70,6 +83,8 @@ input_file_open(struct input_stream *is, const char *filename)
is
->
data
=
GINT_TO_POINTER
(
fd
);
is
->
ready
=
true
;
g_free
(
pathname
);
return
true
;
}
...
...
src/update.c
View file @
ab3d89f4
...
...
@@ -52,6 +52,8 @@
#include <stdlib.h>
#include <errno.h>
#include "decoder_plugin.h"
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "update"
...
...
@@ -213,7 +215,8 @@ directory_exists(const struct directory *directory)
/* invalid path: cannot exist */
return
false
;
test
=
directory
->
device
==
DEVICE_INARCHIVE
test
=
directory
->
device
==
DEVICE_INARCHIVE
||
directory
->
device
==
DEVICE_CONTAINER
?
G_FILE_TEST_IS_REGULAR
:
G_FILE_TEST_IS_DIR
;
...
...
@@ -423,15 +426,87 @@ static void
update_regular_file
(
struct
directory
*
directory
,
const
char
*
name
,
const
struct
stat
*
st
)
{
bool
no_container
=
true
;
const
char
*
suffix
=
uri_get_suffix
(
name
);
const
struct
decoder_plugin
*
plugin
;
#ifdef ENABLE_ARCHIVE
const
struct
archive_plugin
*
archive
;
#endif
if
(
suffix
==
NULL
)
return
;
else
plugin
=
decoder_plugin_from_suffix
(
suffix
,
false
);
if
(
decoder_plugin_from_suffix
(
suffix
,
false
)
!=
NULL
)
{
if
(
plugin
!=
NULL
)
{
if
(
plugin
->
container_scan
!=
NULL
)
{
unsigned
int
tnum
=
0
;
char
*
vtrack
=
NULL
;
struct
song
*
song
=
songvec_find
(
&
directory
->
songs
,
name
);
const
char
*
pathname
=
map_directory_child_fs
(
directory
,
name
);
struct
directory
*
contdir
=
dirvec_find
(
&
directory
->
children
,
name
);
// is there already a song for this file?
if
(
song
!=
NULL
)
{
delete_song
(
directory
,
song
);
song
=
NULL
;
}
// directory exists already
if
(
contdir
!=
NULL
)
{
no_container
=
false
;
// modification time not eq. file mod. time
if
(
contdir
->
mtime
!=
st
->
st_mtime
)
{
g_message
(
"removing directory: %s"
,
pathname
);
delete_directory
(
contdir
);
contdir
=
NULL
;
}
}
// contdir doesn't yet exist
if
(
contdir
==
NULL
)
{
// reset flag if there are no vtracks
no_container
=
true
;
contdir
=
make_subdir
(
directory
,
name
);
contdir
->
mtime
=
st
->
st_mtime
;
contdir
->
device
=
DEVICE_CONTAINER
;
while
((
vtrack
=
plugin
->
container_scan
(
pathname
,
++
tnum
))
!=
NULL
)
{
song
=
songvec_find
(
&
contdir
->
songs
,
vtrack
);
if
(
song
==
NULL
)
{
song
=
song_file_new
(
vtrack
,
contdir
);
if
(
song
==
NULL
)
return
;
// shouldn't be necessary but it's there..
song
->
mtime
=
st
->
st_mtime
;
song
->
tag
=
plugin
->
tag_dup
(
map_directory_child_fs
(
contdir
,
vtrack
));
songvec_add
(
&
contdir
->
songs
,
song
);
song
=
NULL
;
modified
=
true
;
}
no_container
=
false
;
g_free
(
vtrack
);
}
}
}
if
(
no_container
==
true
)
{
struct
song
*
song
=
songvec_find
(
&
directory
->
songs
,
name
);
if
(
song
==
NULL
)
{
...
...
@@ -450,6 +525,7 @@ update_regular_file(struct directory *directory,
delete_song
(
directory
,
song
);
modified
=
true
;
}
}
#ifdef ENABLE_ARCHIVE
}
else
if
((
archive
=
archive_plugin_from_suffix
(
suffix
)))
{
update_archive_file
(
directory
,
name
,
st
,
archive
);
...
...
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