aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-10-20 21:01:55 +0200
committerMax Kellermann <max@duempel.org>2009-10-20 21:01:55 +0200
commitc953d6409dffd476370ba639118cba97bcda2f35 (patch)
tree5920d5d03757ae9fd6fd753dcef7532d07bff96b
parent447e4d3583d3394a25f0fb186f50cea45dd7f797 (diff)
downloadmpd-c953d6409dffd476370ba639118cba97bcda2f35.tar.gz
mpd-c953d6409dffd476370ba639118cba97bcda2f35.tar.xz
mpd-c953d6409dffd476370ba639118cba97bcda2f35.zip
mapper, update, ...: use g_build_filename(), G_DIR_SEPARATOR, ...
Try to be as portable as possible, use GLib path name functions and macros.
-rw-r--r--src/decoder_thread.c2
-rw-r--r--src/input/file_input_plugin.c2
-rw-r--r--src/mapper.c4
-rw-r--r--src/playlist_save.c2
-rw-r--r--src/song_update.c2
-rw-r--r--src/update_walk.c7
-rw-r--r--src/utils.c2
7 files changed, 10 insertions, 11 deletions
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 5140f2ec3..846b12353 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -74,7 +74,7 @@ decoder_file_decode(const struct decoder_plugin *plugin,
assert(decoder->stream_tag == NULL);
assert(decoder->decoder_tag == NULL);
assert(path != NULL);
- assert(path[0] == '/');
+ assert(g_path_is_absolute(path));
assert(dc.state == DECODE_STATE_START);
decoder_unlock();
diff --git a/src/input/file_input_plugin.c b/src/input/file_input_plugin.c
index 5dbbefcce..07c1e4ed6 100644
--- a/src/input/file_input_plugin.c
+++ b/src/input/file_input_plugin.c
@@ -39,7 +39,7 @@ input_file_open(struct input_stream *is, const char *filename)
char* pathname = g_strdup(filename);
- if (filename[0] != '/')
+ if (!g_path_is_absolute(filename))
{
g_free(pathname);
return false;
diff --git a/src/mapper.c b/src/mapper.c
index 71127f51c..a48e12a35 100644
--- a/src/mapper.c
+++ b/src/mapper.c
@@ -169,10 +169,10 @@ map_fs_to_utf8(const char *path_fs)
{
if (music_dir != NULL &&
strncmp(path_fs, music_dir, music_dir_length) == 0 &&
- path_fs[music_dir_length] == '/')
+ G_IS_DIR_SEPARATOR(path_fs[music_dir_length]))
/* remove musicDir prefix */
path_fs += music_dir_length + 1;
- else if (path_fs[0] == '/')
+ else if (G_IS_DIR_SEPARATOR(path_fs[0]))
/* not within musicDir */
return NULL;
diff --git a/src/playlist_save.c b/src/playlist_save.c
index 103a810fb..d56c0f324 100644
--- a/src/playlist_save.c
+++ b/src/playlist_save.c
@@ -54,7 +54,7 @@ playlist_print_uri(FILE *file, const char *uri)
char *s;
if (playlist_saveAbsolutePaths && !uri_has_scheme(uri) &&
- uri[0] != '/')
+ !g_path_is_absolute(uri))
s = map_uri_fs(uri);
else
s = utf8_to_fs_charset(uri);
diff --git a/src/song_update.c b/src/song_update.c
index 4c1c69da2..cfef5861f 100644
--- a/src/song_update.c
+++ b/src/song_update.c
@@ -39,7 +39,7 @@ song_file_load(const char *path, struct directory *parent)
struct song *song;
bool ret;
- assert((parent == NULL) == (*path == '/'));
+ assert((parent == NULL) == g_path_is_absolute(path));
assert(!uri_has_scheme(path));
assert(strchr(path, '\n') == NULL);
diff --git a/src/update_walk.c b/src/update_walk.c
index bf6b0ef15..fe99ea32a 100644
--- a/src/update_walk.c
+++ b/src/update_walk.c
@@ -620,7 +620,7 @@ skip_symlink(const struct directory *directory, const char *utf8_name)
p = buffer;
while (*p == '.') {
- if (p[1] == '.' && p[2] == '/') {
+ if (p[1] == '.' && G_IS_DIR_SEPARATOR(p[2])) {
/* "../" moves to parent directory */
directory = directory->parent;
if (directory == NULL) {
@@ -630,7 +630,7 @@ skip_symlink(const struct directory *directory, const char *utf8_name)
return !follow_outside_symlinks;
}
p += 3;
- } else if (p[1] == '/')
+ } else if (G_IS_DIR_SEPARATOR(p[1]))
/* eliminate "./" */
p += 2;
else
@@ -675,8 +675,7 @@ updateDirectory(struct directory *directory, const struct stat *st)
return false;
}
- exclude_path_fs = g_strconcat(path_fs, G_DIR_SEPARATOR_S,
- ".mpdignore", NULL);
+ exclude_path_fs = g_build_filename(path_fs, ".mpdignore", NULL);
exclude_list = exclude_list_load(exclude_path_fs);
g_free(exclude_path_fs);
diff --git a/src/utils.c b/src/utils.c
index fc27b13c9..933a70a8c 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -44,7 +44,7 @@
char *parsePath(char *path)
{
#ifndef WIN32
- if (path[0] != '/' && path[0] != '~') {
+ if (!g_path_is_absolute(path) && path[0] != '~') {
g_warning("\"%s\" is not an absolute path", path);
return NULL;
} else if (path[0] == '~') {