AP_Logger: file content: log only file name if directory won't fit
This commit is contained in:
parent
09dfcdb574
commit
7b0f059968
@ -1416,6 +1416,13 @@ void AP_Logger::log_file_content(const char *filename)
|
||||
}
|
||||
strncpy(tmp_filename, filename, len);
|
||||
file->filename = tmp_filename;
|
||||
// Remove directory if whole file name will not fit
|
||||
const char * name = strrchr(file->filename, '/');
|
||||
if ((len-1 > sizeof(file->log_filename)) && (name != nullptr)) {
|
||||
strncpy_noterm(file->log_filename, name+1, sizeof(file->log_filename));
|
||||
} else {
|
||||
strncpy_noterm(file->log_filename, file->filename, sizeof(file->log_filename));
|
||||
}
|
||||
if (file_content.head == nullptr) {
|
||||
file_content.tail = file_content.head = file;
|
||||
file_content.fd = -1;
|
||||
@ -1461,7 +1468,7 @@ void AP_Logger::file_content_update(void)
|
||||
struct log_File pkt {
|
||||
LOG_PACKET_HEADER_INIT(LOG_FILE_MSG),
|
||||
};
|
||||
strncpy_noterm(pkt.filename, file->filename, sizeof(pkt.filename));
|
||||
memcpy(pkt.filename, file->log_filename, sizeof(pkt.filename));
|
||||
const auto length = AP::FS().read(file_content.fd, pkt.data, sizeof(pkt.data));
|
||||
if (length <= 0) {
|
||||
AP::FS().close(file_content.fd);
|
||||
|
@ -561,6 +561,7 @@ private:
|
||||
struct file_list {
|
||||
struct file_list *next;
|
||||
const char *filename;
|
||||
char log_filename[16];
|
||||
};
|
||||
struct {
|
||||
struct file_list *head, *tail;
|
||||
|
Loading…
Reference in New Issue
Block a user