Commit f01d7d23 authored by Max Kellermann's avatar Max Kellermann

input/file: don't fall back to parent directory

This code has never made any sense, and has broken some of the archive plugin.
parent 8f7bc70b
ver 0.15.7 (2009/??/??) ver 0.15.7 (2009/??/??)
* input:
- file: don't fall back to parent directory
* tags: * tags:
- id3: fix ID3v1 charset conversion - id3: fix ID3v1 charset conversion
* decoders: * decoders:
......
...@@ -36,25 +36,14 @@ input_file_open(struct input_stream *is, const char *filename) ...@@ -36,25 +36,14 @@ input_file_open(struct input_stream *is, const char *filename)
int fd, ret; int fd, ret;
struct stat st; struct stat st;
char* pathname = g_strdup(filename);
if (filename[0] != '/') if (filename[0] != '/')
{
g_free(pathname);
return false; return false;
}
if (stat(filename, &st) < 0) { fd = open(filename, O_RDONLY);
char* slash = strrchr(pathname, '/');
*slash = '\0';
}
fd = open(pathname, O_RDONLY);
if (fd < 0) { if (fd < 0) {
is->error = errno; is->error = errno;
g_debug("Failed to open \"%s\": %s", g_debug("Failed to open \"%s\": %s",
pathname, g_strerror(errno)); filename, g_strerror(errno));
g_free(pathname);
return false; return false;
} }
...@@ -64,15 +53,13 @@ input_file_open(struct input_stream *is, const char *filename) ...@@ -64,15 +53,13 @@ input_file_open(struct input_stream *is, const char *filename)
if (ret < 0) { if (ret < 0) {
is->error = errno; is->error = errno;
close(fd); close(fd);
g_free(pathname);
return false; return false;
} }
if (!S_ISREG(st.st_mode)) { 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; is->error = EINVAL;
close(fd); close(fd);
g_free(pathname);
return false; return false;
} }
...@@ -86,8 +73,6 @@ input_file_open(struct input_stream *is, const char *filename) ...@@ -86,8 +73,6 @@ input_file_open(struct input_stream *is, const char *filename)
is->data = GINT_TO_POINTER(fd); is->data = GINT_TO_POINTER(fd);
is->ready = true; is->ready = true;
g_free(pathname);
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment