From aff3af67e67290a9a0e2fc6c9fd4e30124d3b5ed Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sun, 7 Jul 2024 12:49:27 +1000 Subject: [PATCH] AP_Logger: remove short-filename compatability code We used to produce files hwih looked like log1.BIN. We moved to 00000001.BIN instead so things collate. This code allowed the autopilot to return data from SD cards which had old logs on them. --- libraries/AP_Logger/AP_Logger_File.cpp | 35 +------------------------- libraries/AP_Logger/AP_Logger_File.h | 2 -- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/libraries/AP_Logger/AP_Logger_File.cpp b/libraries/AP_Logger/AP_Logger_File.cpp index 28719e042f..68c98fe98d 100644 --- a/libraries/AP_Logger/AP_Logger_File.cpp +++ b/libraries/AP_Logger/AP_Logger_File.cpp @@ -366,26 +366,12 @@ void AP_Logger_File::Prep_MinSpace() } while (log_to_remove != first_log_to_remove); } -/* - construct a log file name given a log number. - The number in the log filename will *not* be zero-padded. - Note: Caller must free. - */ -char *AP_Logger_File::_log_file_name_short(const uint16_t log_num) const -{ - char *buf = nullptr; - if (asprintf(&buf, "%s/%u.BIN", _log_directory, (unsigned)log_num) == -1) { - return nullptr; - } - return buf; -} - /* construct a log file name given a log number. The number in the log filename will be zero-padded. Note: Caller must free. */ -char *AP_Logger_File::_log_file_name_long(const uint16_t log_num) const +char *AP_Logger_File::_log_file_name(const uint16_t log_num) const { char *buf = nullptr; if (asprintf(&buf, "%s/%08u.BIN", _log_directory, (unsigned)log_num) == -1) { @@ -394,25 +380,6 @@ char *AP_Logger_File::_log_file_name_long(const uint16_t log_num) const return buf; } -/* - return a log filename appropriate for the supplied log_num if a - filename exists with the short (not-zero-padded name) then it is the - appropirate name, otherwise the long (zero-padded) version is. - Note: Caller must free. - */ -char *AP_Logger_File::_log_file_name(const uint16_t log_num) const -{ - char *filename = _log_file_name_short(log_num); - if (filename == nullptr) { - return nullptr; - } - if (file_exists(filename)) { - return filename; - } - free(filename); - return _log_file_name_long(log_num); -} - /* return path name of the lastlog.txt marker file Note: Caller must free. diff --git a/libraries/AP_Logger/AP_Logger_File.h b/libraries/AP_Logger/AP_Logger_File.h index 8ca4259a1f..c54ac23fd7 100644 --- a/libraries/AP_Logger/AP_Logger_File.h +++ b/libraries/AP_Logger/AP_Logger_File.h @@ -111,8 +111,6 @@ private: /* construct a file name given a log number. Caller must free. */ char *_log_file_name(const uint16_t log_num) const; - char *_log_file_name_long(const uint16_t log_num) const; - char *_log_file_name_short(const uint16_t log_num) const; char *_lastlog_file_name() const; uint32_t _get_log_size(const uint16_t log_num); uint32_t _get_log_time(const uint16_t log_num);