Replay: add option to show progress of log file processed

This commit is contained in:
bugobliterator
2025-04-29 15:44:42 +09:00
committed by Randy Mackay
parent 2afc682995
commit 46bdc83cc7
4 changed files with 55 additions and 1 deletions
+14
View File
@@ -4,6 +4,7 @@
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
@@ -27,6 +28,11 @@ bool AP_LoggerFileReader::open_log(const char *logfile)
if (fd == -1) {
return false;
}
// Get the file size for percentage calculation
struct stat st;
if (AP::FS().stat(logfile, &st) == 0) {
file_size = st.st_size;
}
return true;
}
@@ -100,3 +106,11 @@ bool AP_LoggerFileReader::update()
message_count++;
return handle_msg(f, msg);
}
float AP_LoggerFileReader::get_percent_read()
{
if (file_size == 0) {
return 0.0f;
}
return (float)(bytes_read * 100.0 / file_size);
}