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
da693822
Commit
da693822
authored
Jan 04, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
path: removed pfx_dir()
Use GLib's g_build_filename() instead of pfx_dir().
parent
1a04e571
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
41 deletions
+10
-41
path.c
src/path.c
+0
-17
path.h
src/path.h
+0
-12
stored_playlist.c
src/stored_playlist.c
+4
-6
update.c
src/update.c
+6
-6
No files found.
src/path.c
View file @
da693822
...
@@ -107,20 +107,3 @@ void path_global_finish(void)
...
@@ -107,20 +107,3 @@ void path_global_finish(void)
{
{
g_free
(
fs_charset
);
g_free
(
fs_charset
);
}
}
char
*
pfx_dir
(
char
*
dst
,
const
char
*
path
,
const
size_t
path_len
,
const
char
*
pfx
,
const
size_t
pfx_len
)
{
if
(
G_UNLIKELY
((
pfx_len
+
path_len
+
1
)
>=
MPD_PATH_MAX
))
g_error
(
"Cannot prefix '%s' to '%s', PATH_MAX: %d"
,
pfx
,
path
,
MPD_PATH_MAX
);
/* memmove allows dst == path */
memmove
(
dst
+
pfx_len
+
1
,
path
,
path_len
+
1
);
memcpy
(
dst
,
pfx
,
pfx_len
);
dst
[
pfx_len
]
=
'/'
;
/* this is weird, but directory.c can use it more safely/efficiently */
return
(
dst
+
pfx_len
+
1
);
}
src/path.h
View file @
da693822
...
@@ -44,16 +44,4 @@ void path_set_fs_charset(const char *charset);
...
@@ -44,16 +44,4 @@ void path_set_fs_charset(const char *charset);
const
char
*
path_get_fs_charset
(
void
);
const
char
*
path_get_fs_charset
(
void
);
/*
* pfx_dir - sets dst="$pfx/$path" and returns a pointer to path inside * dst
* this will unconditionally put a '/' between pfx and path unlike
* the static pfx_path() function in path.c
* dst is assumed to be MAXPATHLEN in size
* dst can point to the same location as path, but not pfx, which makes
* this better than sprintf(3) in some cases
*/
char
*
pfx_dir
(
char
*
dst
,
const
char
*
path
,
const
size_t
path_len
,
const
char
*
pfx
,
const
size_t
pfx_len
);
#endif
#endif
src/stored_playlist.c
View file @
da693822
...
@@ -37,13 +37,12 @@ static struct stored_playlist_info *
...
@@ -37,13 +37,12 @@ static struct stored_playlist_info *
load_playlist_info
(
const
char
*
parent_path_fs
,
const
char
*
name_fs
)
load_playlist_info
(
const
char
*
parent_path_fs
,
const
char
*
name_fs
)
{
{
size_t
name_length
=
strlen
(
name_fs
);
size_t
name_length
=
strlen
(
name_fs
);
char
buffer
[
MPD_PATH_MAX
],
*
name
,
*
name_utf8
;
char
buffer
[
MPD_PATH_MAX
],
*
path_fs
,
*
name
,
*
name_utf8
;
int
ret
;
int
ret
;
struct
stat
st
;
struct
stat
st
;
struct
stored_playlist_info
*
playlist
;
struct
stored_playlist_info
*
playlist
;
if
(
name_length
<
1
+
sizeof
(
PLAYLIST_FILE_SUFFIX
)
||
if
(
name_length
<
1
+
sizeof
(
PLAYLIST_FILE_SUFFIX
)
||
strlen
(
parent_path_fs
)
+
name_length
>=
sizeof
(
buffer
)
||
memchr
(
name_fs
,
'\n'
,
name_length
)
!=
NULL
)
memchr
(
name_fs
,
'\n'
,
name_length
)
!=
NULL
)
return
NULL
;
return
NULL
;
...
@@ -53,10 +52,9 @@ load_playlist_info(const char *parent_path_fs, const char *name_fs)
...
@@ -53,10 +52,9 @@ load_playlist_info(const char *parent_path_fs, const char *name_fs)
sizeof
(
PLAYLIST_FILE_SUFFIX
)
-
1
)
!=
0
)
sizeof
(
PLAYLIST_FILE_SUFFIX
)
-
1
)
!=
0
)
return
NULL
;
return
NULL
;
pfx_dir
(
buffer
,
name_fs
,
name_length
,
path_fs
=
g_build_filename
(
parent_path_fs
,
name_fs
,
NULL
);
parent_path_fs
,
strlen
(
parent_path_fs
));
ret
=
stat
(
path_fs
,
&
st
);
g_free
(
path_fs
);
ret
=
stat
(
buffer
,
&
st
);
if
(
ret
<
0
||
!
S_ISREG
(
st
.
st_mode
))
if
(
ret
<
0
||
!
S_ISREG
(
st
.
st_mode
))
return
NULL
;
return
NULL
;
...
...
src/update.c
View file @
da693822
...
@@ -288,16 +288,16 @@ make_subdir(struct directory *parent, const char *name)
...
@@ -288,16 +288,16 @@ make_subdir(struct directory *parent, const char *name)
directory
=
directory_get_child
(
parent
,
name
);
directory
=
directory_get_child
(
parent
,
name
);
if
(
directory
==
NULL
)
{
if
(
directory
==
NULL
)
{
char
path
[
MPD_PATH_MAX
]
;
char
*
path
;
if
(
directory_is_root
(
parent
))
if
(
directory_is_root
(
parent
))
strcpy
(
path
,
name
)
;
path
=
NULL
;
else
else
pfx_dir
(
path
,
name
,
strlen
(
name
),
name
=
path
=
g_strconcat
(
directory_get_path
(
parent
),
directory_get_path
(
parent
),
"/"
,
name
,
NULL
);
strlen
(
directory_get_path
(
parent
)));
directory
=
directory_new_child
(
parent
,
path
);
directory
=
directory_new_child
(
parent
,
name
);
g_free
(
path
);
}
}
return
directory
;
return
directory
;
...
...
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