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

void FileCache::addFile ( QString  url,
QByteArray &  ba 
)

Adds the given data to the cache under the given url. It also checks the cache size and removes files if necessary.

Definition at line 253 of file fileCache.cpp.

References checkCacheSize(), createFilename(), mkpath(), and saveCache().

                                                   {
  QString filename = createFilename(url);

#ifdef DEBUG
  cout << "Cache add: " << filename.latin1() << " size: " << ba.size() << endl;
#endif
  QString filepath = QDir(cacheLocation).filePath(filename);
  QString directory = QDir(filepath + QDir::separator() + "..").absPath();
#ifdef DEBUG
  cout << "Cache dir: " << directory.latin1() << endl;
  cout << "Filepath: " << filepath.latin1() << endl;
#endif
  mkpath(directory);

  QFile file(filepath);
  file.open(IO_WriteOnly);
  file.writeBlock(ba.data(), ba.size());
  file.close();

  QMutexLocker qml(&filesMutex);

  // insert the new file at the top of the list

  files.prepend(filename);
  dirty = true;

  checkCacheSize();

  saveCache();
}


Generated by  Doxygen 1.6.0   Back to index