log files will be deleted after x days

This commit is contained in:
doitux
2007-02-08 18:49:36 +00:00
parent ff18ca3df5
commit 5d5a2fd2ee
+29
View File
@@ -52,6 +52,35 @@ Log::Log(mainWindowImpl* w) : myW(w)
linesInFile = 3;
}
//Zu alte Dateien löschen!!!
int daysUntilWaste = myConfig->readConfigInt("LogStoreDuration");
int i;
QStringList logFileList = myLogDir->entryList(QDir::Files);
logFileList.removeFirst();
for(i=0; i<logFileList.count(); i++) {
// cout << logFileList.at(i).toStdString() << endl;
QString dateString = logFileList.at(i);
dateString.remove("pokerth-log-");
dateString.remove(10,14);
QDate dateOfFile(QDate::fromString(dateString, Qt::ISODate));
QDate today(QDate::currentDate());
// cout << dateOfFile.daysTo(today) << endl;
if (dateOfFile.daysTo(today) > daysUntilWaste) {
// cout << QString::QString(myLogDir->absolutePath()+"/"+logFileList.at(i)).toStdString() << endl;
QFile fileToDelete(myLogDir->absolutePath()+"/"+logFileList.at(i));
fileToDelete.remove();
}
}
}