+ while ((entry = readdir(dir))) {
+ if (!strcmp(entry->d_name, ".")
+ || !strcmp(entry->d_name, "..")) {
+ continue;
+ }
+ switch (entry->d_type) {
+ case DT_DIR:
+ {
+ char output_subpath[PATH_MAX];
+ char input_subpath[PATH_MAX];
+
+ strncpy(output_subpath, output_path,
+ sizeof(output_subpath));
+ output_subpath[sizeof(output_subpath) - 1] = '\0';
+ strncat(output_subpath, "/",
+ sizeof(output_subpath) - strlen(output_subpath) - 1);
+ strncat(output_subpath, entry->d_name,
+ sizeof(output_subpath) - strlen(output_subpath) - 1);
+
+ ret = mkdir(output_subpath, S_IRWXU | S_IRWXG);
+ if (ret) {
+ PERROR("mkdir");
+ has_warning = 1;
+ goto end;
+ }
+
+ strncpy(input_subpath, input_path,
+ sizeof(input_subpath));
+ input_subpath[sizeof(input_subpath) - 1] = '\0';
+ strncat(input_subpath, "/",
+ sizeof(input_subpath) - strlen(input_subpath) - 1);
+ strncat(input_subpath, entry->d_name,
+ sizeof(input_subpath) - strlen(input_subpath) - 1);
+
+ ret = extract_trace_recursive(output_subpath,
+ input_subpath);
+ if (ret) {
+ has_warning = 1;
+ }
+ break;
+ }
+ case DT_REG:
+ case DT_LNK:
+ if (!strcmp(entry->d_name, "metadata")) {
+ ret = extract_one_trace(output_path,
+ input_path);
+ if (ret) {
+ WARN("Error extracting trace '%s', continuing anyway.",
+ input_path);
+ has_warning = 1;
+ }
+ }
+ /* Ignore other files */
+ break;
+ default: