diff --git a/src/comm/MAVLinkProtocol.cc b/src/comm/MAVLinkProtocol.cc index 3b583080c7f7c7f7e1f382d42dcd77ff7f36a159..71e3aa80adc31f2b4c3a146959788cfdc9d015d4 100644 --- a/src/comm/MAVLinkProtocol.cc +++ b/src/comm/MAVLinkProtocol.cc @@ -757,3 +757,15 @@ void MAVLinkProtocol::suspendLogForReplay(bool suspend) _logSuspendReplay = suspend; } + +void MAVLinkProtocol::deleteTempLogFiles(void) +{ + QDir tempDir(QStandardPaths::writableLocation(QStandardPaths::TempLocation)); + + QString filter(QString("*.%1").arg(_logFileExtension)); + QFileInfoList fileInfoList = tempDir.entryInfoList(QStringList(filter), QDir::Files); + + foreach(const QFileInfo fileInfo, fileInfoList) { + QFile::remove(fileInfo.filePath()); + } +} diff --git a/src/comm/MAVLinkProtocol.h b/src/comm/MAVLinkProtocol.h index 070902b7866c544987a47966f25c63d3235a539c..04da4a693bbce237f9a4393c7def3a0518742a70 100644 --- a/src/comm/MAVLinkProtocol.h +++ b/src/comm/MAVLinkProtocol.h @@ -199,6 +199,9 @@ public slots: /// and not called directly in order to synchronize with the bytesReady signal /// which may be ahead of it in the signal queue. void suspendLogForReplay(bool suspend); + + /// @brief Deletes any log files which are in the temp directory + static void deleteTempLogFiles(void); protected: // Override from QObject