Logo Search packages:      
Sourcecode: earth3d version File versions  Download package

void FileCache::checkCacheSize (  )  [protected]

Checks if files from the cache must be deleted to fit the requested cache size.

Definition at line 287 of file fileCache.cpp.

References getUsedSizeBytes(), and removeFile().

Referenced by addFile().

                               {
  QMutexLocker qml(&filesMutex);

  // sum up all file sizes
  long size;
  size = getUsedSizeBytes();

  // check overall size

  long cachesize = getAttribute("cachesize", "50").toInt() * 1024 * 1024;
  if (cachesize<1) cachesize = 1;

  // remove entries from the end until the size is fit

  while(size>cachesize && !files.isEmpty()) {
      
      // get last entry
    QString lastfile = files.last();
    files.pop_back();

#ifdef DEBUG
    cout << "cache removing " << lastfile.latin1() << " current size: " << size << endl;
#endif

    // remove file
    removeFile(QDir(cacheLocation).filePath(lastfile));
    
    // the list has to be saved
    dirty = true;
    
    // calculate new filesize
    size -= filesizes[lastfile];
    filesizes.remove(lastfile);
  }
}


Generated by  Doxygen 1.6.0   Back to index