aboutsummaryrefslogtreecommitdiffstats
path: root/src/input
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 64a4030ab..bda1777ac 100644
--- a/src/input/file_input_plugin.c
+++ b/src/input/file_input_plugin.c
@@ -36,25 +36,14 @@ 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;
- }
- if (stat(filename, &st) < 0) {
- char* slash = strrchr(pathname, '/');
- *slash = '\0';
- }
-
- fd = open(pathname, O_RDONLY);
+ fd = open(filename, O_RDONLY);
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;
}
@@ -64,15 +53,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;
}
@@ -86,8 +73,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;
}