aboutsummaryrefslogtreecommitdiffstats
path: root/src/archive
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-31 10:33:13 +0100
committerMax Kellermann <max@duempel.org>2009-12-31 16:13:09 +0100
commit3ddf7b620cadfdd0b6b20ea78af221cf4b97d247 (patch)
tree1b35b453ad9c59a3de1f8d2bd772a963065ad7ef /src/archive
parent131cb0598a6cd659211d5a468ebf4575da001a95 (diff)
downloadmpd-3ddf7b620cadfdd0b6b20ea78af221cf4b97d247.tar.gz
mpd-3ddf7b620cadfdd0b6b20ea78af221cf4b97d247.tar.xz
mpd-3ddf7b620cadfdd0b6b20ea78af221cf4b97d247.zip
archive/iso9660: added struct iso9660_input_stream
Don't use the iso9660_archive_file object for the input_stream.
Diffstat (limited to 'src/archive')
-rw-r--r--src/archive/iso9660_archive_plugin.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/src/archive/iso9660_archive_plugin.c b/src/archive/iso9660_archive_plugin.c
index ab9ba899b..ff8236663 100644
--- a/src/archive/iso9660_archive_plugin.c
+++ b/src/archive/iso9660_archive_plugin.c
@@ -38,8 +38,6 @@ struct iso9660_archive_file {
struct archive_file base;
iso9660_t *iso;
- iso9660_stat_t *statbuf;
- size_t max_blocks;
GSList *list;
GSList *iter;
};
@@ -157,51 +155,65 @@ iso9660_archive_close(struct archive_file *file)
/* single archive handling */
+struct iso9660_input_stream {
+ struct iso9660_archive_file *archive;
+
+ iso9660_stat_t *statbuf;
+ size_t max_blocks;
+};
+
static bool
iso9660_archive_open_stream(struct archive_file *file, struct input_stream *is,
const char *pathname, GError **error_r)
{
struct iso9660_archive_file *context =
(struct iso9660_archive_file *)file;
+ struct iso9660_input_stream *iis;
- //setup file ops
- is->plugin = &iso9660_input_plugin;
- //insert back reference
- is->data = context;
- //we are not seekable
- is->seekable = false;
-
- context->statbuf = iso9660_ifs_stat_translate (context->iso, pathname);
+ iis = g_new(struct iso9660_input_stream, 1);
- if (context->statbuf == NULL) {
+ iis->archive = context;
+ iis->statbuf = iso9660_ifs_stat_translate(context->iso, pathname);
+ if (iis->statbuf == NULL) {
+ g_free(iis);
g_set_error(error_r, iso9660_quark(), 0,
"not found in the ISO file: %s", pathname);
return false;
}
- is->size = context->statbuf->size;
+ //setup file ops
+ is->plugin = &iso9660_input_plugin;
+ //insert back reference
+ is->data = iis;
+ //we are not seekable
+ is->seekable = false;
+
+ is->size = iis->statbuf->size;
- context->max_blocks = CEILING(context->statbuf->size, ISO_BLOCKSIZE);
+ iis->max_blocks = CEILING(iis->statbuf->size, ISO_BLOCKSIZE);
return true;
}
static void
iso9660_input_close(struct input_stream *is)
{
- struct iso9660_archive_file *context = is->data;
- g_free(context->statbuf);
+ struct iso9660_input_stream *iis =
+ (struct iso9660_input_stream *)is->data;
+
+ g_free(iis->statbuf);
- iso9660_archive_close((struct archive_file *)context);
+ iso9660_archive_close(&iis->archive->base);
}
static size_t
iso9660_input_read(struct input_stream *is, void *ptr, size_t size, GError **error_r)
{
- struct iso9660_archive_file *context = (struct iso9660_archive_file *) is->data;
+ struct iso9660_input_stream *iis =
+ (struct iso9660_input_stream *)is->data;
int toread, readed = 0;
int no_blocks, cur_block;
- size_t left_bytes = context->statbuf->size - is->offset;
+ size_t left_bytes = iis->statbuf->size - is->offset;
size = (size * ISO_BLOCKSIZE) / ISO_BLOCKSIZE;
@@ -216,8 +228,8 @@ iso9660_input_read(struct input_stream *is, void *ptr, size_t size, GError **err
cur_block = is->offset / ISO_BLOCKSIZE;
- readed = iso9660_iso_seek_read (context->iso, ptr,
- context->statbuf->lsn + cur_block, no_blocks);
+ readed = iso9660_iso_seek_read (iis->archive->iso, ptr,
+ iis->statbuf->lsn + cur_block, no_blocks);
if (readed != no_blocks * ISO_BLOCKSIZE) {
g_set_error(error_r, iso9660_quark(), 0,