mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-06 19:00:27 +08:00
Replay: add option to show progress of log file processed
This commit is contained in:
committed by
Randy Mackay
parent
2afc682995
commit
46bdc83cc7
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user