-
- /* metadata */
- strcpy(metafile, "sigrok-meta-XXXXXX");
- if( (tmpfile = g_mkstemp(metafile)) == -1)
- return SIGROK_ERR;
- close(tmpfile);
- make_metadata(metafile);
- if( !(src = zip_source_file(zipfile, metafile, 0, -1)) )
- return SIGROK_ERR;
- if(zip_add(zipfile, "metadata", src) == -1)
- return SIGROK_ERR;
- unlink(metafile);
-
- /* raw */
- devcnt = 1;
- for(l = session->devices; l; l = l->next) {
- device = l->data;
- ds = device->datastore;
- if(ds) {
- buf = malloc(ds->num_units * ds->ds_unitsize + DATASTORE_CHUNKSIZE);
- bufcnt = 0;
- for(d = ds->chunklist; d; d = d->next) {
- memcpy(buf + bufcnt, d->data, DATASTORE_CHUNKSIZE);
- bufcnt += DATASTORE_CHUNKSIZE;
- }
- if( !(src = zip_source_buffer(zipfile, buf, ds->num_units * ds->ds_unitsize, TRUE)) )
- return SIGROK_ERR;
- snprintf(rawname, 15, "raw-%d", devcnt);
- if(zip_add(zipfile, rawname, src) == -1)
- return SIGROK_ERR;
- }
- devcnt++;
- }
-
- if( (ret = zip_close(zipfile)) == -1) {
- g_message("error saving zipfile: %s", zip_strerror(zipfile));
- return SIGROK_ERR;
- }
-
- return SIGROK_OK;