From ab3d89f484d7997e3f6dc0d4bb42c1da9377ba40 Mon Sep 17 00:00:00 2001 From: Jochen Keil Date: Sun, 8 Mar 2009 20:16:53 +0100 Subject: decoder_plugin: added method container_scan() [mk: fixed whitespace errors; use delete_song() instead of songvec_delete()] --- src/input/file_input_plugin.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/input') diff --git a/src/input/file_input_plugin.c b/src/input/file_input_plugin.c index c8a5053f8..6dc815df9 100644 --- a/src/input/file_input_plugin.c +++ b/src/input/file_input_plugin.c @@ -35,12 +35,23 @@ input_file_open(struct input_stream *is, const char *filename) int fd, ret; struct stat st; + char* pathname = g_strdup(filename); + if (filename[0] != '/') + { + g_free(pathname); return false; + } - fd = open(filename, O_RDONLY); + if (stat(filename, &st) < 0) { + char* slash = strrchr(pathname, '/'); + *slash = '\0'; + } + + fd = open(pathname, O_RDONLY); if (fd < 0) { is->error = errno; + g_free(pathname); return false; } @@ -50,13 +61,15 @@ input_file_open(struct input_stream *is, const char *filename) if (ret < 0) { is->error = errno; close(fd); + g_free(pathname); return false; } if (!S_ISREG(st.st_mode)) { - g_debug("Not a regular file: %s\n", filename); + g_debug("Not a regular file: %s", pathname); is->error = EINVAL; close(fd); + g_free(pathname); return false; } @@ -70,6 +83,8 @@ input_file_open(struct input_stream *is, const char *filename) is->data = GINT_TO_POINTER(fd); is->ready = true; + g_free(pathname); + return true; } -- cgit v1.2.3