// this updates all collection files related to the argument file
void CollectionSystemManager::updateCollectionSystems(FileData* file)
{
	// collection files use the full path as key, to avoid clashes
	std::string key = file->getFullPath();
	// find games in collection systems
	for(auto sysIt = SystemData::sSystemVector.begin(); sysIt != SystemData::sSystemVector.end(); sysIt++)
	{
		if ((*sysIt)->isCollection()) {
			const std::unordered_map<std::string, FileData*>& children = (*sysIt)->getRootFolder()->getChildrenByFilename();
			bool found = children.find(key) != children.end();
			FileData* rootFolder = (*sysIt)->getRootFolder();
			FileFilterIndex* fileIndex = (*sysIt)->getIndex();
			std::string name = (*sysIt)->getName();
			if (found) {
				// if we found it, we need to update it
				FileData* collectionEntry = children.at(key);
				// remove from index, so we can re-index metadata after refreshing
				fileIndex->removeFromIndex(collectionEntry);
				collectionEntry->refreshMetadata();
				if (name == "favorites" && file->metadata.get("favorite") == "false") {
					// need to check if still marked as favorite, if not remove
					ViewController::get()->getGameListView((*sysIt)).get()->remove(collectionEntry, false);
					ViewController::get()->onFileChanged((*sysIt)->getRootFolder(), FILE_REMOVED);
				}
				else
				{
					// re-index with new metadata
					fileIndex->addToIndex(collectionEntry);
					ViewController::get()->onFileChanged(collectionEntry, FILE_METADATA_CHANGED);
				}
			}
			else
			{
				// we didn't find it here - we need to check if we should add it
				if (name == "recent" && file->metadata.get("playcount") > "0" ||
					name == "favorites" && file->metadata.get("favorite") == "true") {
					CollectionFileData* newGame = new CollectionFileData(file, (*sysIt));
					rootFolder->addChild(newGame);
					fileIndex->addToIndex(newGame);
					ViewController::get()->onFileChanged(file, FILE_METADATA_CHANGED);
					ViewController::get()->getGameListView((*sysIt))->onFileChanged(newGame, FILE_METADATA_CHANGED);
				}
			}
			rootFolder->sort(getSortType(mCollectionSystemDecls[name].defaultSort));
			ViewController::get()->onFileChanged(rootFolder, FILE_SORTED);
		}
	}
}