From 5ae3d0aa36a4e9c057378e2eb114de6daee37ec2 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 9 Feb 2026 17:26:32 -0500 Subject: [PATCH] core: Track current offset Signed-off-by: Ian Moffett --- src/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index c10bef9..abc4346 100644 --- a/src/main.c +++ b/src/main.c @@ -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; } }