Ejemplo n.º 1
0
void LunarMainWindow::processCacheCleaning()
{
    QDir dir("cache/");
    QFileInfoList listDir = dir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
    int i = 0;
    for(QFileInfoList::iterator it = listDir.begin(); it != listDir.end(); ++it)
    {
        if(it->lastModified().date() <= m_cacheDuration)
        {
            qDebug() << it->lastModified().date() << " " << m_cacheDuration << endl;
            QFile file("cache/" + it->fileName());
            file.remove();
            i++;
        }
    }
    qDebug() << "Cleaned " << i << " expired elements from the cache" << endl;
}