mapper, update, ...: use g_build_filename(), G_DIR_SEPARATOR, ...
Try to be as portable as possible, use GLib path name functions and macros.
This commit is contained in:
parent
447e4d3583
commit
c953d6409d
@ -74,7 +74,7 @@ decoder_file_decode(const struct decoder_plugin *plugin,
|
|||||||
assert(decoder->stream_tag == NULL);
|
assert(decoder->stream_tag == NULL);
|
||||||
assert(decoder->decoder_tag == NULL);
|
assert(decoder->decoder_tag == NULL);
|
||||||
assert(path != NULL);
|
assert(path != NULL);
|
||||||
assert(path[0] == '/');
|
assert(g_path_is_absolute(path));
|
||||||
assert(dc.state == DECODE_STATE_START);
|
assert(dc.state == DECODE_STATE_START);
|
||||||
|
|
||||||
decoder_unlock();
|
decoder_unlock();
|
||||||
|
@ -39,7 +39,7 @@ input_file_open(struct input_stream *is, const char *filename)
|
|||||||
|
|
||||||
char* pathname = g_strdup(filename);
|
char* pathname = g_strdup(filename);
|
||||||
|
|
||||||
if (filename[0] != '/')
|
if (!g_path_is_absolute(filename))
|
||||||
{
|
{
|
||||||
g_free(pathname);
|
g_free(pathname);
|
||||||
return false;
|
return false;
|
||||||
|
@ -169,10 +169,10 @@ map_fs_to_utf8(const char *path_fs)
|
|||||||
{
|
{
|
||||||
if (music_dir != NULL &&
|
if (music_dir != NULL &&
|
||||||
strncmp(path_fs, music_dir, music_dir_length) == 0 &&
|
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 */
|
/* remove musicDir prefix */
|
||||||
path_fs += music_dir_length + 1;
|
path_fs += music_dir_length + 1;
|
||||||
else if (path_fs[0] == '/')
|
else if (G_IS_DIR_SEPARATOR(path_fs[0]))
|
||||||
/* not within musicDir */
|
/* not within musicDir */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ playlist_print_uri(FILE *file, const char *uri)
|
|||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if (playlist_saveAbsolutePaths && !uri_has_scheme(uri) &&
|
if (playlist_saveAbsolutePaths && !uri_has_scheme(uri) &&
|
||||||
uri[0] != '/')
|
!g_path_is_absolute(uri))
|
||||||
s = map_uri_fs(uri);
|
s = map_uri_fs(uri);
|
||||||
else
|
else
|
||||||
s = utf8_to_fs_charset(uri);
|
s = utf8_to_fs_charset(uri);
|
||||||
|
@ -39,7 +39,7 @@ song_file_load(const char *path, struct directory *parent)
|
|||||||
struct song *song;
|
struct song *song;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
assert((parent == NULL) == (*path == '/'));
|
assert((parent == NULL) == g_path_is_absolute(path));
|
||||||
assert(!uri_has_scheme(path));
|
assert(!uri_has_scheme(path));
|
||||||
assert(strchr(path, '\n') == NULL);
|
assert(strchr(path, '\n') == NULL);
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ skip_symlink(const struct directory *directory, const char *utf8_name)
|
|||||||
|
|
||||||
p = buffer;
|
p = buffer;
|
||||||
while (*p == '.') {
|
while (*p == '.') {
|
||||||
if (p[1] == '.' && p[2] == '/') {
|
if (p[1] == '.' && G_IS_DIR_SEPARATOR(p[2])) {
|
||||||
/* "../" moves to parent directory */
|
/* "../" moves to parent directory */
|
||||||
directory = directory->parent;
|
directory = directory->parent;
|
||||||
if (directory == NULL) {
|
if (directory == NULL) {
|
||||||
@ -630,7 +630,7 @@ skip_symlink(const struct directory *directory, const char *utf8_name)
|
|||||||
return !follow_outside_symlinks;
|
return !follow_outside_symlinks;
|
||||||
}
|
}
|
||||||
p += 3;
|
p += 3;
|
||||||
} else if (p[1] == '/')
|
} else if (G_IS_DIR_SEPARATOR(p[1]))
|
||||||
/* eliminate "./" */
|
/* eliminate "./" */
|
||||||
p += 2;
|
p += 2;
|
||||||
else
|
else
|
||||||
@ -675,8 +675,7 @@ updateDirectory(struct directory *directory, const struct stat *st)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
exclude_path_fs = g_strconcat(path_fs, G_DIR_SEPARATOR_S,
|
exclude_path_fs = g_build_filename(path_fs, ".mpdignore", NULL);
|
||||||
".mpdignore", NULL);
|
|
||||||
exclude_list = exclude_list_load(exclude_path_fs);
|
exclude_list = exclude_list_load(exclude_path_fs);
|
||||||
g_free(exclude_path_fs);
|
g_free(exclude_path_fs);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
char *parsePath(char *path)
|
char *parsePath(char *path)
|
||||||
{
|
{
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
if (path[0] != '/' && path[0] != '~') {
|
if (!g_path_is_absolute(path) && path[0] != '~') {
|
||||||
g_warning("\"%s\" is not an absolute path", path);
|
g_warning("\"%s\" is not an absolute path", path);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (path[0] == '~') {
|
} else if (path[0] == '~') {
|
||||||
|
Loading…
Reference in New Issue
Block a user