void traverse_product() { int result; result = coda_open(traverse_info.file_name, &traverse_info.pf); if (result != 0 && coda_errno == CODA_ERROR_FILE_OPEN) { /* maybe not enough memory space to map the file in memory => * temporarily disable memory mapping of files and try again */ coda_set_option_use_mmap(0); result = coda_open(traverse_info.file_name, &traverse_info.pf); coda_set_option_use_mmap(1); } if (result != 0) { handle_coda_error(); } if (coda_cursor_set_product(&traverse_info.cursor, traverse_info.pf) != 0) { handle_coda_error(); } if (coda_get_product_root_type(traverse_info.pf, &traverse_info.type[traverse_info.current_depth]) != 0) { handle_coda_error(); } traverse_data(); coda_close(traverse_info.pf); traverse_info.pf = NULL; }
static int coda_match_file(coda_expression *expr, NameBuffer *path_name, int (*callback) (const char *, coda_filefilter_status, const char *, void *), void *userdata) { coda_product *product; coda_cursor cursor; int filter_result; int result; result = coda_open(path_name->buffer, &product); if (result != 0 && coda_errno == CODA_ERROR_FILE_OPEN) { /* maybe not enough memory space to map the file in memory => * temporarily disable memory mapping of files and try again */ coda_set_option_use_mmap(0); result = coda_open(path_name->buffer, &product); coda_set_option_use_mmap(1); } if (result != 0) { if (coda_errno == CODA_ERROR_UNSUPPORTED_PRODUCT) { return callback(path_name->buffer, coda_ffs_unsupported_file, NULL, userdata); } else { return callback(path_name->buffer, coda_ffs_could_not_open_file, coda_errno_to_string(coda_errno), userdata); } } if (coda_cursor_set_product(&cursor, product) != 0) { coda_close(product); return callback(path_name->buffer, coda_ffs_error, coda_errno_to_string(coda_errno), userdata); } if (coda_expression_eval_bool(expr, &cursor, &filter_result) != 0) { return callback(path_name->buffer, coda_ffs_error, coda_errno_to_string(coda_errno), userdata); } coda_close(product); return callback(path_name->buffer, filter_result ? coda_ffs_match : coda_ffs_no_match, NULL, userdata); }