MCPcopy Create free account
hub / github.com/bumptop/BumpTop / CleanUpSceneFiles

Function CleanUpSceneFiles

trunk/win/Source/BT_Util.cpp:7851–7914  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7849}
7850
7851void CleanUpSceneFiles()
7852{
7853 LibraryManager* libManager = winOS->GetLibraryManager();
7854 if (!libManager)
7855 return;
7856
7857 QDir dir(winOS->GetDataDirectory());
7858 QStringList filters;
7859 filters << QT_NT("*.bump") << QT_NT("*.bump.bak");
7860 QStringList files = dir.entryList(filters);
7861
7862 const QList< QSharedPointer<Library> >& libraries = libManager->getLibraries();
7863 QListIterator< QSharedPointer<Library> > iter(libraries);
7864 while (iter.hasNext())
7865 {
7866 const QSharedPointer<Library>& lib = iter.next();
7867
7868 QString sceneFileName;
7869 QString sceneFileNameBak;
7870 if (lib->getHashKey().startsWith(QT_NT("def_")))
7871 {
7872 sceneFileName = QString_NT("scene.pb.bump");
7873 sceneFileNameBak = QString_NT("scene.pb.bump.bak");
7874 }
7875 else if (lib->getHashKey().startsWith(QT_NT("lib_")))
7876 {
7877 sceneFileName = QString_NT("%1_scene.pb.bump").arg(lib->getName());
7878 sceneFileNameBak = sceneFileName + QT_NT(".bak");
7879 }
7880 else
7881 {
7882 QString sceneHash = QString(QCryptographicHash::hash(lib->getFolderPaths().front().toUtf8(), QCryptographicHash::Md5).toHex());
7883 sceneFileName = QString_NT("%1_scene.pb.bump").arg(sceneHash);
7884 sceneFileNameBak = sceneFileName + QT_NT(".bak");
7885 }
7886
7887 bool mainTested = false;
7888 bool backUpTested = false;
7889 QMutableStringListIterator fileIter(files);
7890 while (fileIter.hasNext() && !(backUpTested && mainTested))
7891 {
7892 QString filePath = fileIter.next();
7893 if (filePath == sceneFileName)
7894 {
7895 fileIter.remove();
7896 mainTested = true;
7897
7898 }
7899 if (filePath == sceneFileNameBak)
7900 {
7901 fileIter.remove();
7902 backUpTested = true;
7903 }
7904 }
7905 }
7906
7907 // Erase files that still exist
7908 QStringListIterator fileIter(files);

Callers 1

InitMethod · 0.85

Calls 14

GetLibraryManagerMethod · 0.80
GetDataDirectoryMethod · 0.80
getLibrariesMethod · 0.80
hasNextMethod · 0.80
getHashKeyMethod · 0.80
getFolderPathsMethod · 0.80
QStringFunction · 0.50
hashClass · 0.50
nextMethod · 0.45
startsWithMethod · 0.45
argMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected