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
0a0b4737
Commit
0a0b4737
authored
Feb 13, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mapper: add mapper_get_music_directory()
Shortcut for map_directory_fs(db_get_root()).
parent
df2d0414
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
29 deletions
+25
-29
inotify_update.c
src/inotify_update.c
+12
-21
mapper.c
src/mapper.c
+3
-3
mapper.h
src/mapper.h
+9
-2
playlist_song.c
src/playlist_song.c
+1
-3
No files found.
src/inotify_update.c
View file @
0a0b4737
...
...
@@ -266,18 +266,19 @@ mpd_inotify_callback(int wd, unsigned mask,
(
mask
&
IN_ISDIR
)
!=
0
)
{
/* a sub directory was changed: register those in
inotify */
char
*
root
=
map_directory_fs
(
db_get_root
());
char
*
path_fs
;
if
(
uri_fs
!=
NULL
)
{
path_fs
=
g_strconcat
(
root
,
"/"
,
uri_fs
,
NULL
);
g_free
(
root
);
}
else
const
char
*
root
=
mapper_get_music_directory
();
const
char
*
path_fs
;
char
*
allocated
=
NULL
;
if
(
uri_fs
!=
NULL
)
path_fs
=
allocated
=
g_strconcat
(
root
,
"/"
,
uri_fs
,
NULL
);
else
path_fs
=
root
;
recursive_watch_subdirectories
(
directory
,
path_fs
,
watch_directory_depth
(
directory
));
g_free
(
path_fs
);
g_free
(
allocated
);
}
if
((
mask
&
(
IN_CLOSE_WRITE
|
IN_MOVE
|
IN_DELETE
))
!=
0
||
...
...
@@ -303,21 +304,13 @@ mpd_inotify_callback(int wd, unsigned mask,
void
mpd_inotify_init
(
unsigned
max_depth
)
{
struct
directory
*
root
;
char
*
path
;
GError
*
error
=
NULL
;
g_debug
(
"initializing inotify"
);
root
=
db_get_root
();
if
(
root
==
NULL
)
{
g_debug
(
"no music directory configured"
);
return
;
}
path
=
map_directory_fs
(
root
);
const
char
*
path
=
mapper_get_music_directory
();
if
(
path
==
NULL
)
{
g_
warning
(
"mapper has fail
ed"
);
g_
debug
(
"no music directory configur
ed"
);
return
;
}
...
...
@@ -326,13 +319,12 @@ mpd_inotify_init(unsigned max_depth)
if
(
inotify_source
==
NULL
)
{
g_warning
(
"%s"
,
error
->
message
);
g_error_free
(
error
);
g_free
(
path
);
return
;
}
inotify_max_depth
=
max_depth
;
inotify_root
.
name
=
path
;
inotify_root
.
name
=
g_strdup
(
path
)
;
inotify_root
.
descriptor
=
mpd_inotify_source_add
(
inotify_source
,
path
,
IN_MASK
,
&
error
);
if
(
inotify_root
.
descriptor
<
0
)
{
...
...
@@ -340,7 +332,6 @@ mpd_inotify_init(unsigned max_depth)
g_error_free
(
error
);
mpd_inotify_source_free
(
inotify_source
);
inotify_source
=
NULL
;
g_free
(
path
);
return
;
}
...
...
src/mapper.c
View file @
0a0b4737
...
...
@@ -117,10 +117,10 @@ void mapper_finish(void)
g_free
(
playlist_dir
);
}
bool
mapper_
has
_music_directory
(
void
)
const
char
*
mapper_
get
_music_directory
(
void
)
{
return
music_dir
!=
NULL
;
return
music_dir
;
}
const
char
*
...
...
src/mapper.h
View file @
0a0b4737
...
...
@@ -36,12 +36,19 @@ void mapper_init(const char *_music_dir, const char *_playlist_dir);
void
mapper_finish
(
void
);
G_GNUC_CONST
const
char
*
mapper_get_music_directory
(
void
);
/**
* Returns true if a music directory was configured.
*/
G_GNUC_CONST
bool
mapper_has_music_directory
(
void
);
static
inline
bool
mapper_has_music_directory
(
void
)
{
return
mapper_get_music_directory
()
!=
NULL
;
}
/**
* If the specified absolute path points inside the music directory,
...
...
src/playlist_song.c
View file @
0a0b4737
...
...
@@ -115,7 +115,7 @@ playlist_check_translate_song(struct song *song, const char *base_uri,
if
(
g_path_is_absolute
(
uri
))
{
/* XXX fs_charset vs utf8? */
c
har
*
prefix
=
map_directory_fs
(
db_get_root
()
);
c
onst
char
*
prefix
=
mapper_get_music_directory
(
);
if
(
prefix
!=
NULL
&&
g_str_has_prefix
(
uri
,
prefix
)
&&
uri
[
strlen
(
prefix
)]
==
'/'
)
...
...
@@ -123,13 +123,11 @@ playlist_check_translate_song(struct song *song, const char *base_uri,
else
if
(
!
secure
)
{
/* local files must be relative to the music
directory when "secure" is enabled */
g_free
(
prefix
);
song_free
(
song
);
return
NULL
;
}
base_uri
=
NULL
;
g_free
(
prefix
);
}
if
(
base_uri
!=
NULL
)
...
...
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