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
7366191f
Commit
7366191f
authored
Oct 15, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mapper: moved musicDir initialization from path.c
Moved the musicDir variable and its initialization code from path.c to mapper.c.
parent
76779f0f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
31 deletions
+52
-31
main.c
src/main.c
+3
-0
mapper.c
src/mapper.c
+45
-6
mapper.h
src/mapper.h
+4
-0
path.c
src/path.c
+0
-20
path.h
src/path.h
+0
-5
No files found.
src/main.c
View file @
7366191f
...
...
@@ -26,6 +26,7 @@
#include "listen.h"
#include "conf.h"
#include "path.h"
#include "mapper.h"
#include "playerData.h"
#include "outputBuffer.h"
#include "decoder_thread.h"
...
...
@@ -410,6 +411,7 @@ int main(int argc, char *argv[])
open_log_files
(
options
.
stdOutput
);
initPaths
();
mapper_init
();
initPermissions
();
initPlaylist
();
decoder_plugin_init_all
();
...
...
@@ -477,6 +479,7 @@ int main(int argc, char *argv[])
finishAudioDriver
();
finishAudioConfig
();
finishVolume
();
mapper_finish
();
finishPaths
();
finishPermissions
();
dc_deinit
();
...
...
src/mapper.c
View file @
7366191f
...
...
@@ -24,13 +24,54 @@
#include "directory.h"
#include "song.h"
#include "path.h"
#include "conf.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <glib.h>
static
char
*
music_dir
;
static
size_t
music_dir_length
;
void
mapper_init
(
void
)
{
ConfigParam
*
music_dir_param
=
parseConfigFilePath
(
CONF_MUSIC_DIR
,
1
);
int
ret
;
struct
stat
st
;
music_dir
=
g_strdup
(
music_dir_param
->
value
);
music_dir_length
=
strlen
(
music_dir
);
ret
=
stat
(
music_dir
,
&
st
);
if
(
ret
<
0
)
g_error
(
"failed to stat music directory
\"
%s
\"
(config line %i): %s
\n
"
,
music_dir_param
->
value
,
music_dir_param
->
line
,
strerror
(
errno
));
else
if
(
!
S_ISDIR
(
st
.
st_mode
))
g_error
(
"music directory is not a directory:
\"
%s
\"
(config line %i)
\n
"
,
music_dir_param
->
value
,
music_dir_param
->
line
);
}
void
mapper_finish
(
void
)
{
g_free
(
music_dir
);
}
static
char
*
rmp2amp_r
(
char
*
dst
,
const
char
*
rel_path
)
{
pfx_dir
(
dst
,
rel_path
,
strlen
(
rel_path
),
(
const
char
*
)
music_dir
,
music_dir_length
);
return
dst
;
}
const
char
*
map_directory_fs
(
const
struct
directory
*
directory
,
char
*
buffer
)
{
const
char
*
dirname
=
directory_get_path
(
directory
);
if
(
isRootDirectory
(
dirname
))
return
music
D
ir
;
return
music
_d
ir
;
return
rmp2amp_r
(
buffer
,
utf8_to_fs_charset
(
buffer
,
dirname
));
}
...
...
@@ -63,12 +104,10 @@ map_song_fs(const struct song *song, char *buffer)
const
char
*
map_fs_to_utf8
(
const
char
*
path_fs
,
char
*
buffer
)
{
size_t
music_path_length
=
strlen
(
musicDir
);
if
(
strncmp
(
path_fs
,
musicDir
,
music_path_length
)
==
0
&&
path_fs
[
music_path_length
]
==
'/'
)
if
(
strncmp
(
path_fs
,
music_dir
,
music_dir_length
)
==
0
&&
path_fs
[
music_dir_length
]
==
'/'
)
/* remove musicDir prefix */
path_fs
+=
music_
path
_length
;
path_fs
+=
music_
dir
_length
;
else
if
(
path_fs
[
0
]
==
'/'
)
/* not within musicDir */
return
NULL
;
...
...
src/mapper.h
View file @
7366191f
...
...
@@ -26,6 +26,10 @@
struct
directory
;
struct
song
;
void
mapper_init
(
void
);
void
mapper_finish
(
void
);
/**
* Determines the file system path of a directory object.
*
...
...
src/path.c
View file @
7366191f
...
...
@@ -33,9 +33,7 @@
#include <glib.h>
const
char
*
musicDir
;
static
const
char
*
playlistDir
;
static
size_t
music_dir_len
;
static
size_t
playlist_dir_len
;
static
char
*
fsCharset
;
...
...
@@ -100,7 +98,6 @@ const char *getFsCharset(void)
void
initPaths
(
void
)
{
ConfigParam
*
musicParam
=
parseConfigFilePath
(
CONF_MUSIC_DIR
,
1
);
ConfigParam
*
playlistParam
=
parseConfigFilePath
(
CONF_PLAYLIST_DIR
,
1
);
ConfigParam
*
fsCharsetParam
=
getConfigParam
(
CONF_FS_CHARSET
);
...
...
@@ -108,10 +105,7 @@ void initPaths(void)
char
*
originalLocale
;
DIR
*
dir
;
musicDir
=
xstrdup
(
musicParam
->
value
);
playlistDir
=
xstrdup
(
playlistParam
->
value
);
music_dir_len
=
strlen
(
musicDir
);
playlist_dir_len
=
strlen
(
playlistDir
);
if
((
dir
=
opendir
(
playlistDir
))
==
NULL
)
{
...
...
@@ -121,13 +115,6 @@ void initPaths(void)
}
else
closedir
(
dir
);
if
((
dir
=
opendir
(
musicDir
))
==
NULL
)
{
ERROR
(
"cannot open %s
\"
%s
\"
(config line %i): %s
\n
"
,
CONF_MUSIC_DIR
,
musicParam
->
value
,
musicParam
->
line
,
strerror
(
errno
));
}
else
closedir
(
dir
);
if
(
fsCharsetParam
)
{
charset
=
xstrdup
(
fsCharsetParam
->
value
);
}
...
...
@@ -195,13 +182,6 @@ char *pfx_dir(char *dst,
return
(
dst
+
pfx_len
+
1
);
}
char
*
rmp2amp_r
(
char
*
dst
,
const
char
*
rel_path
)
{
pfx_dir
(
dst
,
rel_path
,
strlen
(
rel_path
),
(
const
char
*
)
musicDir
,
music_dir_len
);
return
dst
;
}
char
*
rpp2app_r
(
char
*
dst
,
const
char
*
rel_path
)
{
pfx_dir
(
dst
,
rel_path
,
strlen
(
rel_path
),
...
...
src/path.h
View file @
7366191f
...
...
@@ -31,8 +31,6 @@
# endif
#endif
extern
const
char
*
musicDir
;
void
initPaths
(
void
);
void
finishPaths
(
void
);
...
...
@@ -57,9 +55,6 @@ char *pfx_dir(char *dst,
const
char
*
path
,
const
size_t
path_len
,
const
char
*
pfx
,
const
size_t
pfx_len
);
/* relative music path to absolute music path */
char
*
rmp2amp_r
(
char
*
dst
,
const
char
*
rel_path
);
/* relative playlist path to absolute playlist path */
char
*
rpp2app_r
(
char
*
dst
,
const
char
*
rel_path
);
...
...
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