aboutsummaryrefslogtreecommitdiffstats
path: root/src/input/file_input_plugin.c
diff options
context:
space:
mode:
authorJochen Keil <jochen.keil@gmail.com>2009-03-08 20:16:53 +0100
committerMax Kellermann <max@duempel.org>2009-03-09 07:58:26 +0100
commitab3d89f484d7997e3f6dc0d4bb42c1da9377ba40 (patch)
treea0cd18bc4d69c9f090b9b79c8c2acf4ead9fc2a4 /src/input/file_input_plugin.c
parent94d1a87d0432d885756f9d23cfba1f8229cfe453 (diff)
downloadmpd-ab3d89f484d7997e3f6dc0d4bb42c1da9377ba40.tar.gz
mpd-ab3d89f484d7997e3f6dc0d4bb42c1da9377ba40.tar.xz
mpd-ab3d89f484d7997e3f6dc0d4bb42c1da9377ba40.zip
decoder_plugin: added method container_scan()
[mk: fixed whitespace errors; use delete_song() instead of songvec_delete()]
Diffstat (limited to 'src/input/file_input_plugin.c')
-rw-r--r--src/input/file_input_plugin.c19
1 files changed, 17 insertions, 2 deletions
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;
}