-
Notifications
You must be signed in to change notification settings - Fork 80
API_xar_file_next
Rob Braun edited this page Jun 28, 2008
·
3 revisions
Obtain a reference to the next file in a xarchive
libxar uses iterators for browsing through the files in a xarchive, or propertie s associated with files. xar_file_next() takes an iterator previously allocated with a call to xar_iter_new() and initialized with a call to xar_file_first(). xar_file_next() will then return a reference to the next file in the xarchive. This function is meant to allow linear iteration over the files in a xarchive.
Upon success, xar_file_next() will return a reference to the next file in the xarchive. On failure, NULL will be returned.
#include <xar/xar.h> int main(int argc, char *argv[]) { xar_t x; xar_file_t f; xar_iter_t i; x = xar_open(argv[1], READ); if( x == NULL ) { fprintf(stderr, "Error opening xarchive: %s\n", argv[1]); exit(1); } i = xar_iter_new(x); if( !i ) { fprintf(stderr, "Error obtaining a new iterator\n"); exit(1); } for(f = xar_file_first(x, i); f; f = xar_file_next(i)) { xar_extract(x, f); } ... xar_iter_free(i); xar_close(x); ... }