aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-15 18:59:03 +0100
committerMax Kellermann <max@duempel.org>2009-12-15 19:03:11 +0100
commit95c3f283ea5a50a344b63af82718ac765229e8da (patch)
tree8f215b0c01202faa2ccf7fbb4ec86a324954a3fd
parentaef6609f4f9464ae9f33febcd3967d8df50c220b (diff)
downloadmpd-95c3f283ea5a50a344b63af82718ac765229e8da.tar.gz
mpd-95c3f283ea5a50a344b63af82718ac765229e8da.tar.xz
mpd-95c3f283ea5a50a344b63af82718ac765229e8da.zip
input/file: don't fall back to parent directory
This code has never made any sense, and has broken some of the archive plugin.
-rw-r--r--src/input/file_input_plugin.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/input/file_input_plugin.c b/src/input/file_input_plugin.c
index 8561d04e7..73dcf4c0f 100644
--- a/src/input/file_input_plugin.c
+++ b/src/input/file_input_plugin.c
@@ -38,25 +38,14 @@ input_file_open(struct input_stream *is, const char *filename)
int fd, ret;
struct stat st;
- char* pathname = g_strdup(filename);
-
if (!g_path_is_absolute(filename))
- {
- g_free(pathname);
return false;
- }
- if (stat(filename, &st) < 0) {
- char* slash = strrchr(pathname, '/');
- *slash = '\0';
- }
-
- fd = open_cloexec(pathname, O_RDONLY, 0);
+ fd = open_cloexec(filename, O_RDONLY, 0);
if (fd < 0) {
is->error = errno;
g_debug("Failed to open \"%s\": %s",
- pathname, g_strerror(errno));
- g_free(pathname);
+ filename, g_strerror(errno));
return false;
}
@@ -66,15 +55,13 @@ 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", pathname);
+ g_debug("Not a regular file: %s", filename);
is->error = EINVAL;
close(fd);
- g_free(pathname);
return false;
}
@@ -88,8 +75,6 @@ input_file_open(struct input_stream *is, const char *filename)
is->data = GINT_TO_POINTER(fd);
is->ready = true;
- g_free(pathname);
-
return true;
}