decoder_plugin: added method container_scan()

[mk: fixed whitespace errors; use delete_song() instead of
songvec_delete()]
This commit is contained in:
Jochen Keil
2009-03-08 20:16:53 +01:00
committed by Max Kellermann
parent 94d1a87d04
commit ab3d89f484
5 changed files with 137 additions and 21 deletions

View File

@@ -35,12 +35,23 @@ input_file_open(struct input_stream *is, const char *filename)
int fd, ret;
struct stat st;
if (filename[0] != '/')
return false;
char* pathname = g_strdup(filename);
fd = open(filename, O_RDONLY);
if (filename[0] != '/')
{
g_free(pathname);
return false;
}
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;
}