diff options
author | Max Kellermann <max@duempel.org> | 2009-12-16 16:40:22 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-12-16 17:10:19 +0100 |
commit | 71fee0974402702c16b40dc6791196c46fb038bb (patch) | |
tree | 4e6270b610d56092970ea31193d09adf59490ae6 /src | |
parent | f9af1a445efedc049a6a608a76088578e3cca4b3 (diff) | |
download | mpd-71fee0974402702c16b40dc6791196c46fb038bb.tar.gz mpd-71fee0974402702c16b40dc6791196c46fb038bb.tar.xz mpd-71fee0974402702c16b40dc6791196c46fb038bb.zip |
archive_plugin: use GError in the open() method
Diffstat (limited to 'src')
-rw-r--r-- | src/archive/bz2_archive_plugin.c | 5 | ||||
-rw-r--r-- | src/archive/iso9660_archive_plugin.c | 5 | ||||
-rw-r--r-- | src/archive/zzip_archive_plugin.c | 5 | ||||
-rw-r--r-- | src/archive_plugin.c | 9 | ||||
-rw-r--r-- | src/archive_plugin.h | 5 | ||||
-rw-r--r-- | src/input/archive_input_plugin.c | 2 | ||||
-rw-r--r-- | src/update_walk.c | 6 |
7 files changed, 23 insertions, 14 deletions
diff --git a/src/archive/bz2_archive_plugin.c b/src/archive/bz2_archive_plugin.c index e8e5c556c..b3a9027af 100644 --- a/src/archive/bz2_archive_plugin.c +++ b/src/archive/bz2_archive_plugin.c @@ -98,7 +98,7 @@ bz2_destroy(struct bz2_archive_file *data) /* archive open && listing routine */ static struct archive_file * -bz2_open(const char *pathname) +bz2_open(const char *pathname, GError **error_r) { struct bz2_archive_file *context; int len; @@ -107,8 +107,7 @@ bz2_open(const char *pathname) archive_file_init(&context->base, &bz2_archive_plugin); //open archive - if (!input_stream_open(&context->istream, pathname, NULL)) { - g_warning("failed to open an bzip2 archive %s\n",pathname); + if (!input_stream_open(&context->istream, pathname, error_r)) { g_free(context); return NULL; } diff --git a/src/archive/iso9660_archive_plugin.c b/src/archive/iso9660_archive_plugin.c index ccab9e614..780268df8 100644 --- a/src/archive/iso9660_archive_plugin.c +++ b/src/archive/iso9660_archive_plugin.c @@ -90,7 +90,7 @@ listdir_recur(const char *psz_path, struct iso9660_archive_file *context) } static struct archive_file * -iso9660_archive_open(const char *pathname) +iso9660_archive_open(const char *pathname, GError **error_r) { struct iso9660_archive_file *context = g_new(struct iso9660_archive_file, 1); @@ -102,7 +102,8 @@ iso9660_archive_open(const char *pathname) /* open archive */ context->iso = iso9660_open (pathname); if (context->iso == NULL) { - g_warning("iso %s open failed\n", pathname); + g_set_error(error_r, iso9660_quark(), 0, + "Failed to open ISO9660 file %s", pathname); return NULL; } diff --git a/src/archive/zzip_archive_plugin.c b/src/archive/zzip_archive_plugin.c index 1174629ae..43c880aab 100644 --- a/src/archive/zzip_archive_plugin.c +++ b/src/archive/zzip_archive_plugin.c @@ -52,7 +52,7 @@ zzip_quark(void) /* archive open && listing routine */ static struct archive_file * -zzip_archive_open(const char *pathname) +zzip_archive_open(const char *pathname, GError **error_r) { struct zzip_archive *context = g_malloc(sizeof(*context)); ZZIP_DIRENT dirent; @@ -63,7 +63,8 @@ zzip_archive_open(const char *pathname) context->list = NULL; context->dir = zzip_dir_open(pathname, NULL); if (context->dir == NULL) { - g_warning("zipfile %s open failed\n", pathname); + g_set_error(error_r, zzip_quark(), 0, + "Failed to open ZIP file %s", pathname); return NULL; } diff --git a/src/archive_plugin.c b/src/archive_plugin.c index 2626c53fb..86334709b 100644 --- a/src/archive_plugin.c +++ b/src/archive_plugin.c @@ -23,15 +23,17 @@ #include <assert.h> struct archive_file * -archive_file_open(const struct archive_plugin *plugin, const char *path) +archive_file_open(const struct archive_plugin *plugin, const char *path, + GError **error_r) { struct archive_file *file; assert(plugin != NULL); assert(plugin->open != NULL); assert(path != NULL); + assert(error_r == NULL || *error_r == NULL); - file = plugin->open(path); + file = plugin->open(path, error_r); if (file != NULL) { assert(file->plugin != NULL); @@ -39,6 +41,9 @@ archive_file_open(const struct archive_plugin *plugin, const char *path) assert(file->plugin->scan_reset != NULL); assert(file->plugin->scan_next != NULL); assert(file->plugin->open_stream != NULL); + assert(error_r == NULL || *error_r == NULL); + } else { + assert(error_r == NULL || *error_r != NULL); } return file; diff --git a/src/archive_plugin.h b/src/archive_plugin.h index 1c35293d1..52629f2e1 100644 --- a/src/archive_plugin.h +++ b/src/archive_plugin.h @@ -48,7 +48,7 @@ struct archive_plugin { * returns pointer to handle used is all operations with this archive * or NULL when opening fails */ - struct archive_file *(*open)(const char *path_fs); + struct archive_file *(*open)(const char *path_fs, GError **error_r); /** * reset routine will move current read index in archive to default @@ -90,7 +90,8 @@ struct archive_plugin { }; struct archive_file * -archive_file_open(const struct archive_plugin *plugin, const char *path); +archive_file_open(const struct archive_plugin *plugin, const char *path, + GError **error_r); void archive_file_close(struct archive_file *file); diff --git a/src/input/archive_input_plugin.c b/src/input/archive_input_plugin.c index 15070f91a..53d472a5a 100644 --- a/src/input/archive_input_plugin.c +++ b/src/input/archive_input_plugin.c @@ -61,7 +61,7 @@ input_archive_open(struct input_stream *is, const char *pathname, return false; } - file = archive_file_open(arplug, archive); + file = archive_file_open(arplug, archive, error_r); if (file == NULL) return false; diff --git a/src/update_walk.c b/src/update_walk.c index f6f924bd6..db3111326 100644 --- a/src/update_walk.c +++ b/src/update_walk.c @@ -394,6 +394,7 @@ update_archive_file(struct directory *parent, const char *name, const struct stat *st, const struct archive_plugin *plugin) { + GError *error = NULL; char *path_fs; struct archive_file *file; struct directory *directory; @@ -409,10 +410,11 @@ update_archive_file(struct directory *parent, const char *name, path_fs = map_directory_child_fs(parent, name); /* open archive */ - file = archive_file_open(plugin, path_fs); + file = archive_file_open(plugin, path_fs, &error); if (file == NULL) { - g_warning("unable to open archive %s", path_fs); g_free(path_fs); + g_warning("%s", error->message); + g_error_free(error); return; } |