core: Track current offset

Signed-off-by: Ian Moffett <ian@mirocom.org>
This commit is contained in:
2026-02-09 17:26:32 -05:00
parent ab90d89092
commit 5ae3d0aa36

View File

@@ -20,12 +20,14 @@ static const char *output_name = "out.cav";
* @dir: Opened directory
* @pass_count: Number of passes made in file
* @file_count: Number of files encountered including subdirectories
* @cur_off: Current offset tracker
*/
struct cav_state {
int dir_fd;
DIR *dir;
uint8_t pass_count;
size_t file_count;
uint32_t cur_off;
};
static void
@@ -133,7 +135,9 @@ consume_scan(const char *dir_path, struct cav_state *state, DIR *subdir)
closedir(subdir);
break;
default:
snprintf(buf, sizeof(buf), "%s/%s", dir_path, dirent->d_name);
++state->file_count;
state->cur_off += get_file_size(buf);
break;
}
}
@@ -155,7 +159,11 @@ consume_pass(struct cav_state *state)
case 0:
/* Scan pass */
consume_scan(input_name, state, NULL);
printf("[pass 0] scanned %zu files\n", state->file_count);
printf(
"[pass 0] scanned %zu files [%d bytes]\n",
state->file_count,
state->cur_off
);
break;
}
}