aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-04 19:37:19 +0100
committerMax Kellermann <max@duempel.org>2009-01-04 19:37:19 +0100
commitda693822730d1712d44da85389e4d8b659b3b5df (patch)
treec6af7f8c5eab082cbdab029066b8f8758906d6b3 /src
parent1a04e571686ea9c9bfca2701564a41f7d9d12a9e (diff)
downloadmpd-da693822730d1712d44da85389e4d8b659b3b5df.tar.gz
mpd-da693822730d1712d44da85389e4d8b659b3b5df.tar.xz
mpd-da693822730d1712d44da85389e4d8b659b3b5df.zip
path: removed pfx_dir()
Use GLib's g_build_filename() instead of pfx_dir().
Diffstat (limited to '')
-rw-r--r--src/path.c17
-rw-r--r--src/path.h12
-rw-r--r--src/stored_playlist.c10
-rw-r--r--src/update.c12
4 files changed, 10 insertions, 41 deletions
diff --git a/src/path.c b/src/path.c
index 19a1f4151..2698957f7 100644
--- a/src/path.c
+++ b/src/path.c
@@ -107,20 +107,3 @@ void path_global_finish(void)
{
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);
-}
diff --git a/src/path.h b/src/path.h
index e99c02f05..3bb088b5f 100644
--- a/src/path.h
+++ b/src/path.h
@@ -44,16 +44,4 @@ void path_set_fs_charset(const char *charset);
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
diff --git a/src/stored_playlist.c b/src/stored_playlist.c
index 3504c0a26..a503c2841 100644
--- a/src/stored_playlist.c
+++ b/src/stored_playlist.c
@@ -37,13 +37,12 @@ static struct stored_playlist_info *
load_playlist_info(const char *parent_path_fs, const char *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;
struct stat st;
struct stored_playlist_info *playlist;
if (name_length < 1 + sizeof(PLAYLIST_FILE_SUFFIX) ||
- strlen(parent_path_fs) + name_length >= sizeof(buffer) ||
memchr(name_fs, '\n', name_length) != NULL)
return NULL;
@@ -53,10 +52,9 @@ load_playlist_info(const char *parent_path_fs, const char *name_fs)
sizeof(PLAYLIST_FILE_SUFFIX) - 1) != 0)
return NULL;
- pfx_dir(buffer, name_fs, name_length,
- parent_path_fs, strlen(parent_path_fs));
-
- ret = stat(buffer, &st);
+ path_fs = g_build_filename(parent_path_fs, name_fs, NULL);
+ ret = stat(path_fs, &st);
+ g_free(path_fs);
if (ret < 0 || !S_ISREG(st.st_mode))
return NULL;
diff --git a/src/update.c b/src/update.c
index f792b3c3c..7f5185ccb 100644
--- a/src/update.c
+++ b/src/update.c
@@ -288,16 +288,16 @@ make_subdir(struct directory *parent, const char *name)
directory = directory_get_child(parent, name);
if (directory == NULL) {
- char path[MPD_PATH_MAX];
+ char *path;
if (directory_is_root(parent))
- strcpy(path, name);
+ path = NULL;
else
- pfx_dir(path, name, strlen(name),
- directory_get_path(parent),
- strlen(directory_get_path(parent)));
+ name = path = g_strconcat(directory_get_path(parent),
+ "/", name, NULL);
- directory = directory_new_child(parent, path);
+ directory = directory_new_child(parent, name);
+ g_free(path);
}
return directory;