- struct ctf_trace *trace = container_of(td, struct ctf_trace, parent);
-
- g_ptr_array_add(tc->array, td);
-
- if (tc->array->len > 1) {
- struct clock_match clock_match = {
- .clocks = tc->clocks,
- .clock_match = NULL,
- };
-
- /*
- * With two or more traces, we need correlation info
- * avalable.
- */
- g_hash_table_foreach(trace->clocks,
- check_clock_match,
- &clock_match);
- if (!clock_match.clock_match) {
- fprintf(stderr, "[error] No clocks can be correlated and multiple traces are added to the collection.\n");
- goto error;
+ int ret = 0, trace_ids = 0;
+
+ if ((strncmp(path, NET4_URL_PREFIX, sizeof(NET4_URL_PREFIX) - 1)) == 0 ||
+ (strncmp(path, NET6_URL_PREFIX, sizeof(NET6_URL_PREFIX) - 1)) == 0 ||
+ (strncmp(path, NET_URL_PREFIX, sizeof(NET_URL_PREFIX) - 1)) == 0) {
+ ret = bt_context_add_trace(ctx,
+ path, format_str, packet_seek, NULL, NULL);
+ if (ret < 0) {
+ fprintf(stderr, "[warning] [Context] cannot open trace \"%s\" "
+ "for reading.\n", path);
+ }
+ return ret;
+ }
+ /* Should lock traversed_paths mutex here if used in multithread */
+
+ traversed_paths = g_ptr_array_new();
+ ret = nftw(path, traverse_trace_dir, 10, 0);
+
+ /* Process the array if ntfw did not return a fatal error */
+ if (ret >= 0) {
+ int i;
+
+ for (i = 0; i < traversed_paths->len; i++) {
+ GString *trace_path = g_ptr_array_index(traversed_paths,
+ i);
+ int trace_id = bt_context_add_trace(ctx,
+ trace_path->str,
+ format_str,
+ packet_seek,
+ NULL,
+ NULL);
+ if (trace_id < 0) {
+ fprintf(stderr, "[warning] [Context] cannot open trace \"%s\" from %s "
+ "for reading.\n", trace_path->str, path);
+ /* Allow to skip erroneous traces. */
+ ret = 1; /* partial error */
+ } else {
+ trace_ids++;
+ }
+ g_string_free(trace_path, TRUE);