- if (!vdev->capfile) {
- /* No capture file opened yet, or finished with the last
- * chunked one. */
- if (vdev->cur_chunk == 0) {
- /* capturefile is always the unchunked base name. */
- if (zip_stat(vdev->archive, vdev->capturefile, 0, &zs) != -1) {
- /* No chunks, just a single capture file. */
- vdev->cur_chunk = 0;
- if (!(vdev->capfile = zip_fopen(vdev->archive,
- vdev->capturefile, 0)))
- return FALSE;
- sr_dbg("Opened %s.", vdev->capturefile);
- } else {
- /* Try as first chunk filename. */
- snprintf(capturefile, 15, "%s-1", vdev->capturefile);
- if (zip_stat(vdev->archive, capturefile, 0, &zs) != -1) {
- vdev->cur_chunk = 1;
- if (!(vdev->capfile = zip_fopen(vdev->archive,
- capturefile, 0)))
- return FALSE;
- sr_dbg("Opened %s.", capturefile);
- } else {
- sr_err("No capture file '%s' in " "session file '%s'.",
- vdev->capturefile, vdev->sessionfile);
- return FALSE;
- }
- }
- } else {
- /* Capture data is chunked, advance to the next chunk. */
- vdev->cur_chunk++;
- snprintf(capturefile, 15, "%s-%d", vdev->capturefile,
- vdev->cur_chunk);
- if (zip_stat(vdev->archive, capturefile, 0, &zs) != -1) {
- if (!(vdev->capfile = zip_fopen(vdev->archive,
- capturefile, 0)))
- return FALSE;
- sr_dbg("Opened %s.", capturefile);
- } else {
- /* We got all the chunks, finish up. */
- g_free(vdev->capturefile);
- g_free(vdev);
- sdi->priv = NULL;
- continue;
- }
- }
- }
-