aboutsummaryrefslogtreecommitdiffstats
path: root/src/update.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-20 22:18:12 +0200
committerMax Kellermann <max@duempel.org>2008-10-20 22:18:12 +0200
commitba96920a52bbd2208aa1f3b284edc864e26198ce (patch)
tree6750d817780ef892d82e0ce0aecaebd54546799a /src/update.c
parent99e82a2ef293429e3fcc4f6e5d8e7981b4351c7c (diff)
downloadmpd-ba96920a52bbd2208aa1f3b284edc864e26198ce.tar.gz
mpd-ba96920a52bbd2208aa1f3b284edc864e26198ce.tar.xz
mpd-ba96920a52bbd2208aa1f3b284edc864e26198ce.zip
path: replaced mpd_basename() with g_path_get_basename()
GLib's g_path_get_basename() is much more reliable than mpd_basename(). The latter could be tricked into an assertion failure.
Diffstat (limited to '')
-rw-r--r--src/update.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/update.c b/src/update.c
index 58a55cf9c..5ab75d7ac 100644
--- a/src/update.c
+++ b/src/update.c
@@ -32,6 +32,8 @@
#include "update.h"
#include "idle.h"
+#include <glib.h>
+
static enum update_progress {
UPDATE_PROGRESS_IDLE = 0,
UPDATE_PROGRESS_RUNNING = 1,
@@ -407,6 +409,7 @@ static struct directory *
directory_make_child_checked(struct directory *parent, const char *path)
{
struct directory *directory;
+ char *basename;
struct stat st;
struct song *conflicting;
@@ -414,16 +417,22 @@ directory_make_child_checked(struct directory *parent, const char *path)
if (directory != NULL)
return directory;
- if (stat_directory_child(parent, mpd_basename(path), &st) < 0 ||
- inodeFoundInParent(parent, st.st_ino, st.st_dev))
+ basename = g_path_get_basename(path);
+
+ if (stat_directory_child(parent, basename, &st) < 0 ||
+ inodeFoundInParent(parent, st.st_ino, st.st_dev)) {
+ g_free(basename);
return NULL;
+ }
/* if we're adding directory paths, make sure to delete filenames
with potentially the same name */
- conflicting = songvec_find(&parent->songs, mpd_basename(path));
+ conflicting = songvec_find(&parent->songs, basename);
if (conflicting)
delete_song(parent, conflicting);
+ g_free(basename);
+
directory = directory_new_child(parent, path);
directory_set_stat(directory, &st);
return directory;
@@ -455,19 +464,21 @@ static void
updatePath(const char *path)
{
struct directory *parent;
- const char *name;
+ char *name;
struct stat st;
parent = addParentPathToDB(path);
if (parent == NULL)
return;
- name = mpd_basename(path);
+ name = g_path_get_basename(path);
if (stat_directory_child(parent, name, &st) == 0)
updateInDirectory(parent, name, &st);
else
delete_name_in(parent, name);
+
+ g_free(name);
}
static void * update_task(void *_path)